Hello. I try to do a row by row insertion to a specified database table. Yet i keep getting that error despite the fact that i got both columns and values count right.
SqlConnection cnn3 = new SqlConnection(cb.ConnectionString);
cnn3.Open();
cnn3.ChangeDatabase(DatabaseInProcess.DbInProcess);
SqlCommand cmd3 = new SqlCommand(
@"INSERT INTO DestinationDatabase.dbo." + table.tableName + " (" + columns + ") VALUES (@ValuesParam)"
, cnn3);
cmd3.Parameters.AddWithValue("@ValuesParam", result);
cmd3.ExecuteNonQuery();
Is the code that does the insertion. When i check the sqlCommand cmd3 with Visual Studio viewer i see:
"INSERT INTO DestinationDatabase.dbo.QvBranch (BranchPK, BranchCode, BranchName, BranchIsCentral, BranchIsActive, DataState, DataTime, DataUserFK, DataID) VALUES (@ValuesParam)"
loaded and when i check @ValuesParam i see:
{'f8d4848b-e27c-4351-b8a4-6858a1147059', '0000', 'New Department', '0', '0', NULL, NULL, NULL, NULL}
as an SQL value. As you can see they seem to match up but i still get the error.
Thanks for help.