Hello all. I wasn't sure if I should post this here or under DB?

I'm a PHP user that is new to C#/ASP.NET/MS SQL.

I have a table with rows of string values (not sure why they were made strings as they are numbers but thats what they are).

I have a variable TheNumber that is Int. I am trying to convert that to string and insert it into the DB but I keep getting the type clash error. DBConnection is previously defined with the correct connection string.

Here is the code (the error is on the 2nd to last line that starts WriteToDB:

	   string TempTheNumber = Convert.ToString(TheNumber);
	   String MyString = @"INSERT INTO assignedaccountnums VALUES(" + TempTheNumber + ")";	   
	   SqlCommand WriteToDB = new SqlCommand(MyString, DBConnection);

Any help would be appreciated!

Does it count if you finally figure out your own problem? :-)


String MyString = @"INSERT INTO assignedaccountnums VALUES(" + TempTheNumber + ")";

Should have been this:

String MyString = @"INSERT INTO assignedaccountnums(accountnum) VALUES('" + TempTheNumber + "')";


This question has already been answered. Start a new discussion instead.