Help required on SqlCeParameter to minimise hairloss

Discussion in 'ASP .Net Mobile' started by AndyBrew, Mar 7, 2007.

  1. AndyBrew

    AndyBrew Guest

    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
     
    AndyBrew, Mar 7, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SenthilVel

    Help Required for Help Context Id !!!!!!

    SenthilVel, Nov 30, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,192
    SenthilVel
    Dec 14, 2005
  2. Just D.
    Replies:
    0
    Views:
    464
    Just D.
    Mar 10, 2006
  3. Replies:
    2
    Views:
    482
    Thomas G. Marshall
    Nov 19, 2005
  4. Replies:
    3
    Views:
    1,981
    =?ISO-8859-1?Q?G=E9rard_Talbot?=
    Nov 29, 2006
  5. Simon
    Replies:
    2
    Views:
    558
    Sajid
    Apr 12, 2011
Loading...

Share This Page