The following error occurs during project Compilation:
A syntax error occurs when you convert a string to uniqueidentifier.
Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information to learn about this error andCodeDetailed information about the cause of the error.
Exception details: system. Data. sqlclient. sqlexception: A syntax error occurs when the string is converted to uniqueidentifier.
Source error:
Line 110: fdataset = new dataset ();
Line 111: If (init_ SQL .length> 0)
Line 112: fdataadapter. Fill (fdataset );
Row 113:
Row 114 :}
The reason is as follows:
the parameter type is inconsistent with the database field type. The database field type is uniqueidentifier, in the Program , the parameter type is string and needs to be converted. Conversion Method: string guid = system. guid. newguid (). tostring (); // or system. guid. empty. tostring ();
system. guid G = New GUID (guid); // convert a database field to a guid type when assigning a value
or do not define it as a string type. It is directly defined as a guid type, for example,
set
Public static readonly string zerouniqueid = "{00000000-0000-0000-0000-000000000000 }"; // indicates a nonexistent ID.
changed to
Public static readonly guid zerouniqueid = system. guid. empty; // indicates a non-existent number.
in this way, you can assign values to database fields without any conversion.