How can I convert text string to varbinary?
View Complete Post
I am trying to get the UserRole from the logged in user and send it to the database table my code is:
SqlParameter FamilyFriendsOther = new SqlParameter("@Role", SqlDbType.UniqueIdentifier);
string  roles = System.Web.Security.Roles.GetRolesForUser();
if (roles.Length > 0)
FamilyFriendsOther.Value = roles;
Being a newbie to SSIS I'm not sure of the most efficient method of converting a DateTime object to a String.
I'm from a C# background where this would be easy using DateTime.ToString("YYYYMMdd"). I want to use the date in a file name so don't require most of the parts.
I'm sure I could do this using a script task to produce a file name for each row of data in my table and add that filename to the dataset but it seem like overkill to do something that should be simple. AlsoÃÂ as I'm supposed to be getting to grips with SSIS I shouldn't keep running back to what I know.
My current approach is to derive a column and build up an expression to convert the date into a string. The only problem being that it doesn't work.
The expression I'm working with is:
(DT_WSTR, 50)([OrgName] ) + "_" + (DT_WSTR, 50)( [PayrollName] ) + (DT_WSTR, 4)(YEAR( [ProcessedDate] )) + (DT_WSTR, 2)(MONTH( [ProcessedDate] )) + (DT_WSTR, 2)(DAY( [ProcessedDate] )) ".txt"
Can anyone see where I'm going wrong?
All comments greatly received.
I have a form in which I display data from a database table, change the data and then update the database table. The form consists of textboxes, so all data displayed in the form is string. However - one data is int in the database table (the rest is varchar), so I need to convert it from string to int when I update the database table. How do I do it?
protected void SaveProd_Click(object sender, EventArgs e)
string BildID = TextBoxProdPictID.Text;
string namn = TextBoxProdName.Text;
string kategori = TextBoxProdCategory.Text;
string stl = TextBoxProdSize.Text;
string pris = TextBoxProdPrice.Text;
string iLager = TextBoxProdNumberOf.Text; //this is int in the database table
SqlConnection conn = new SqlConnection(config);
string sql = "UPDATE Produkter SET kategori ='" + kategori + "', namn ='" + namn + "', stl ='" + stl + "', pris ='" + pris + "', iLager ='" + iLager + "' WHERE ID ='" + ID + "'";
SqlCommand comm = new SqlCommand(sql, conn);//Conversion failed when converting the varchar value '__Page' to data type int.
SqlDataReader dr = comm.ExecuteReader();