R
Roger Webb
Hey All,
I have the code below to run a built up SQL string. Column1 is a Identity
Column, and Column2 is a varchar(10). The sqlString below gives me an
System.Data.SqlException Exception that says, "Cannot insert the value NULL
into column 'Column1', table 'TestTable';column does not allow nulls.
Insert fails." when the sqlCommand.ExecuteNonQuery() gets run.
Obviously since its an Identity field, it cant be null; however, if I give
it a value... it doesnt run the identity value into the field.
Anyone have any ideas? I didnt see any previous threads about this.
- Roger
----------------------------------------
SqlConnection sqlConnection = new SqlConnection(TheConnectionString);
SqlCommand sqlCommand = new SqlCommand(sqlString,sqlConnection);
sqlCommand.Connection.Open();
sqlCommand.ExecuteNonQuery();
sqlConnection.Close();
Where sqlString looks like
INSERT INTO TABLE1 (Column2) VALUES ("Hey")
I have the code below to run a built up SQL string. Column1 is a Identity
Column, and Column2 is a varchar(10). The sqlString below gives me an
System.Data.SqlException Exception that says, "Cannot insert the value NULL
into column 'Column1', table 'TestTable';column does not allow nulls.
Insert fails." when the sqlCommand.ExecuteNonQuery() gets run.
Obviously since its an Identity field, it cant be null; however, if I give
it a value... it doesnt run the identity value into the field.
Anyone have any ideas? I didnt see any previous threads about this.
- Roger
----------------------------------------
SqlConnection sqlConnection = new SqlConnection(TheConnectionString);
SqlCommand sqlCommand = new SqlCommand(sqlString,sqlConnection);
sqlCommand.Connection.Open();
sqlCommand.ExecuteNonQuery();
sqlConnection.Close();
Where sqlString looks like
INSERT INTO TABLE1 (Column2) VALUES ("Hey")