Help required on SqlCeParameter to minimise hairloss

A

AndyBrew

Hi

Firstly I apologise if this is the wrong forum but I couldn't seem to find a
forum dedicated to SqlCe or any other mobile forum other than this one???

Secondly, I have written a data access function that adds a record into a
table into my database for which I have done many others, however this table
has a column of type UniqueIdentifier which allows nulls and the row I am
attempting to add does infact have a null value within this column. The code
I use to add the parameter is: -

obSqlCeParameter = new System.Data.SqlServerCe.SqlCeParameter("@parentguid",
System.Data.SqlDbType.UniqueIdentifier);
obSqlCeParameter.IsNullable = true;
obSqlCeParameter.Value =
Caboodal.MIS.Mobile.Utility.Convert.ToSQLDBGuid(parentguid);
obSqlCeCommand.Parameters.Add(obSqlCeParameter);

This function Caboodal.MIS.Mobile.Utility.Convert.ToSQLDBGuid(parentguid);
simply takes the string representation of my Guid and returns either a
System.Guid type or System.DBNull.Value if the string is in a non valid Guid
format.

After calling the Prepare function an exception is raised which produces the
following message: -

{" [ 1,isnull ]"}
base {System.SystemException}: {" [ 1,isnull ]"}
Errors: {System.Data.SqlServerCe.SqlCeErrorCollection}
errors: {System.Data.SqlServerCe.SqlCeErrorCollection}
HResult: -2147217900
Message: " [ 1,isnull ]"
NativeError: 25922
Source: "SQL Server Compact Edition ADO.NET Data Provider"

I have tried all sorts with regards adding in the value as "" and also as
null in place of the System.DBNull.Value value that I assumed would be
correct as it would in normal ADO.NET.

So how do I add a NULL value as a parameter into my SQL statement?

Thanks in advance

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top