I have this piece of code and I want to make it varchar not string. What is the appropriate syntax to do that in c#
string emri = row[\"Nome\"].ToString();
NO this is untrue, When you step through a process by changing the debugging settings located in VS you can step through a SQL script process also if you run an example like this where a table has varchar values set into it.
Try
{
using (SqlCommand cmd = new SqlCommand(examplestring, connection))
{
cmd.ExecutenonQuery();
}
}
catch
{
return;
}
now put a breakpoint onto the catch statement and in the examplestring have a string called '456789 - 1' equal to Itemnumber varchar(25) in the SQL table.
The catch will get the following error SqlException was caught - Error converting data type varchar to numeric.
Now query string is set as a string cause that is the only way the SqlCommand works look it up on MSDN : System.Data.SqlClient.SqlCommand
So yes Lasse there is varchar in .NET.