sql server saves only null values for some columns

82 Views Asked by At

I have a table with some nvarchar(max), varchar(100) and bit type columns. I am inserting values to it programmatically using SQLCommand.ExecuteNonQuery().

I am providing string values to all the nvarchar and varchar columns and 0 or 1 to bit column using SQLParametr.AddWithValue("@parameterName", parameterValue)

For some columns it is storing proper values but for some only null values are getting stored even after providing proper parameter values. Columns in which null values are stored are of type varchar(100) and bit.

In development environment everything works fine, issue occurs in testing environment.

The insert query looks like "INSERT INTO SOME_TABLE(Col1,Col2,Col3,Col4) VAlues(@param1, @param2, @param3, @param4)"

Parameter values are proper even in testing environment tested the same by printing the values to a log file.

Any explanation for this unusual behavior.

1

There are 1 best solutions below

0
On BEST ANSWER

@Lasse V. Karlsen, you were right in a way(A handwaving answer would be that this should work), It turns out to be a silly problem.

All the queries were written in a separate class file which were referenced in the project via add project reference(dll).

I recently made some changes in the class file(Queries) and re-deployed, In dev environment it was working fine but in testing environment, the solution is still referencing the old dll hence old queries, In which I am not passing any values at all and the columns were allow null true, hence storing null values.

Uninstalling the old dll from GAC and installing the new dll fixed the issue