saturation
asked on
ASP.NET SQL insert error with primary key field
I am using an InsertCommand to insert into my data table, but when the form gets submitted, I get the following error:
"System.Data.SqlClient.Sql Exception: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query." -- The pers_personid field below is type "UniqueIdentifier" and is set as the primary key.
My InsertCommand:
InsertCommand="INSERT INTO [tblDCPersonTest] ([pers_firstname], [pers_middlename], [pers_lastname], [pers_ssn], [pers_dob], [pers_phonehome], [pers_phonework], [pers_personid]) VALUES (@pers_firstname, @pers_middlename, @pers_lastname, @pers_ssn, @pers_dob, @pers_phonehome, @pers_phonework, @pers_personid)"
How do I fix this?
"System.Data.SqlClient.Sql
My InsertCommand:
InsertCommand="INSERT INTO [tblDCPersonTest] ([pers_firstname], [pers_middlename], [pers_lastname], [pers_ssn], [pers_dob], [pers_phonehome], [pers_phonework], [pers_personid]) VALUES (@pers_firstname, @pers_middlename, @pers_lastname, @pers_ssn, @pers_dob, @pers_phonehome, @pers_phonework, @pers_personid)"
How do I fix this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
System.Data.SqlClient.SqlE
Did I set my primary key to be the wrong data type? I just want it to start at 1 and increment automatically when a record is inserted.