Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error-Cannot Insert NULL value into col 'rowguid' ?? 1

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hello -
I am using VB6 with a SQL Server 7 database.

When I update the recordset (ex: rsLoadId.Update)...get this error:

btnOpenSpur_Click: 01000: [ODBC SQL Server Driver] The statement has been terminated.
23000: [SQL Server] Cannot insert the value NULL into column 'rowguid', table 'frigdare.dbo.LoadId';
column does not allow nulls. INSERT fails.
Error: 40002=> '01000:[SQL Server] The statement has been terminated' Occurred at line : 100


and Line 100 is rsLoadId.Update


Of course, I do no move anything into the rowguid column,
so I am puzzled by this error...

Does anyone know why this would occur ??

Thanks for any ideas.



 
The error occurs either because the SQL is inserting a new row into the table, but without a value in the rowguid column. With no value, it tries to place a NULL in the column, which the table has been told not to accept.

Otherwise, it is updating the row, and rowguid is part of the update statement, but still with no value.

Check the rs.LoadId Update procedure and see if it is passing an INSERT or an UPDATE command to the SQL server

Tim
 
Tim - here is more info.

Pgm is ADDING a rec.

rsloadId.AddNew
.
. populate the columns...
.
.
rsLoadId.Update

Thanks, John
 
more clarification....

My VB program does not pass anything to rowguid.

VB/SQL Server assigns the value automatically... or am I wrong ?

Thanks, John
 
You need to use the NEWID() function in SQLS to populate the column; this is easiest by setting it as the default in the table definition. Robert Bradley
teaser.jpg

 
Thanks everyone.

This was happening with a database that I copied over to my
Test server; and I had not noticed that it did not bring over the defaults such as (newid()) and getdate().

Aftet I added those, everything is OK now.

Case closed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top