guid

Last post 10-05-2006 5:27 PM by DannyDep. 2 replies.

Sort Posts:

  • guid

    12-01-2005, 8:03 PM
    • Participant
      782 point Participant
    • pzmrcd
    • Member since 07-17-2002, 9:51 AM
    • Posts 194
    Hi
    I have a col in the db table as unique identifier.I generate a new guid and save it into db.
    I am having to use  System.Guid.NewGuid.tostring  to get the guid but this ..it cannot save as it is a string..I tried changing it to a varchar (when assigning as cmd param) no use as

    System.Guid.NewGuid as is will not return anything ..actually is empty without tostring. It will not allow me to cast string to guid either...How can I save this string (GUID) as a uniqeidentifier in the db.

    Thanks

  • Re: guid

    12-03-2005, 1:33 AM
    Answer
    • Contributor
      5,654 point Contributor
    • Eilon
    • Member since 06-26-2002, 2:14 PM
    • Redmond, WA
    • Posts 965
    • AspNetTeam

    What database are you using? I've never had a problem with Microsoft SQL Server. I just say something along these lines:

     

    Guid g = Guid.NewGuid();

    SqlParameter param = new SqlParameter();

    param.ParameterName = "id";

    param.Value = g;

    SqlCommand cmd = new SqlCommand(...);

    cmd.Parameters.Add(param);

    And then execute the command.

     

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: guid

    10-05-2006, 5:27 PM
    • Member
      749 point Member
    • DannyDep
    • Member since 10-18-2005, 7:40 PM
    • Posts 316

    Eilon,

    Could you give us an example of how you would write the code for storing the GUID in an MS Access DB?

    thx,

    ciao, Dan

Page 1 of 1 (3 items)