Professional Web Applications Themes

GUID as a parameter - Microsoft SQL / MS SQL Server

Why are you dynamically creating the parameter name? Should this not be fixed and you just pass in myTable.myGuid? "Ian Williamson" <iwilliamsonit3solutions.com> wrote in message news:110c01c33ce1$42b87980$a101280aphx.gbl... > Greetings, > > I am trying to use a GUID as a parameter within my DA > Update method but I am having troubles formatting it > correctly. Anyone familiar with this? I am doing this > using CE, but I imagine the functionality is the same for > SS2000. > > This code assumes a dataset exists (myDataset). > > SqlCeConnection myConn = new SqlCeConnection > (myConnection); > SqlCeDataAdapter myDataAdapter = new ...

  1. #1

    Default Re: GUID as a parameter

    Why are you dynamically creating the parameter name? Should this not be
    fixed and you just pass in myTable.myGuid?


    "Ian Williamson" <iwilliamsonit3solutions.com> wrote in message
    news:110c01c33ce1$42b87980$a101280aphx.gbl...
    > Greetings,
    >
    > I am trying to use a GUID as a parameter within my DA
    > Update method but I am having troubles formatting it
    > correctly. Anyone familiar with this? I am doing this
    > using CE, but I imagine the functionality is the same for
    > SS2000.
    >
    > This code assumes a dataset exists (myDataset).
    >
    > SqlCeConnection myConn = new SqlCeConnection
    > (myConnection);
    > SqlCeDataAdapter myDataAdapter = new SqlCeDataAdapter();
    > myDataAdapter.DeleteCommand = new SqlCeCommand();
    > myDataAdapter.DeleteCommand.Connection = myConn;
    > myDataAdapter.DeleteCommand.CommandText = "DELETE FROM
    > myTable WHERE (myGuid = ?)";
    > myDataAdapter.DeleteCommand.Parameters.Add("" +
    > myTable.myGuid, SqlDbType.UniqueIdentifier, 0,
    > myTable.myGuid);
    >
    > myConn.Open();
    >
    > try
    > {
    > myDataAdapter.Update(myDataset, "myTable");
    > }
    > catch (SqlCeException se)
    > {
    > }
    >
    >
    > Cheers, Ian Williamson
    >
    >

    Guest

  2. #2

    Default GUID as a parameter

    (repost using our MSDN subscriber account.)

    Greetings,

    I am trying to use a GUID as a parameter within my DA
    Update method but I am having troubles formatting it
    correctly. Anyone familiar with this? I am doing this
    using CE, but I imagine the functionality is the same for
    SS2000.

    This code assumes a dataset exists (myDataset).

    SqlCeConnection myConn = new SqlCeConnection
    (myConnection);
    SqlCeDataAdapter myDataAdapter = new SqlCeDataAdapter();
    myDataAdapter.DeleteCommand = new SqlCeCommand();
    myDataAdapter.DeleteCommand.Connection = myConn;
    myDataAdapter.DeleteCommand.CommandText = "DELETE FROM
    myTable WHERE (myGuid = ?)";
    myDataAdapter.DeleteCommand.Parameters.Add("" +
    myTable.myGuid, SqlDbType.UniqueIdentifier, 0,
    myTable.myGuid);

    myConn.Open();

    try
    {
    myDataAdapter.Update(myDataset, "myTable");
    }
    catch (SqlCeException se)
    {
    }


    Cheers, Ian Williamson


    Ian Williamson Guest

  3. #3

    Default GUID as a parameter

    Seems something was simply amiss with my current state of
    Windows or VS.NET. After a reboot this code executes
    just fine. Go figure.

    >-----Original Message-----
    >Greetings,
    >
    >I am trying to use a GUID as a parameter within my DA
    >Update method but I am having troubles formatting it
    >correctly. Anyone familiar with this? I am doing this
    >using CE, but I imagine the functionality is the same
    for
    >SS2000.
    >
    >This code assumes a dataset exists (myDataset).
    >
    >SqlCeConnection myConn = new SqlCeConnection
    >(myConnection);
    >SqlCeDataAdapter myDataAdapter = new SqlCeDataAdapter();
    >myDataAdapter.DeleteCommand = new SqlCeCommand();
    >myDataAdapter.DeleteCommand.Connection = myConn;
    >myDataAdapter.DeleteCommand.CommandText = "DELETE FROM
    >myTable WHERE (myGuid = ?)";
    >myDataAdapter.DeleteCommand.Parameters.Add("" +
    >myTable.myGuid, SqlDbType.UniqueIdentifier, 0,
    >myTable.myGuid);
    >
    >myConn.Open();
    >
    >try
    >{
    > myDataAdapter.Update(myDataset, "myTable");
    >}
    >catch (SqlCeException se)
    >{
    >}
    >
    >
    >Cheers, Ian Williamson
    >.
    >
    Ian Williamson Guest

Similar Threads

  1. GUID and CFProcParam
    By DeliK in forum Coldfusion Database Access
    Replies: 5
    Last Post: June 23rd, 11:03 PM
  2. SQL: AutoCreating a not-so-unique GUID?
    By darrel in forum Dreamweaver AppDev
    Replies: 0
    Last Post: May 18th, 08:46 PM
  3. GUID question
    By Rob in forum ASP.NET Security
    Replies: 3
    Last Post: January 22nd, 07:28 PM
  4. Retrieving GUID from DB2 UDB
    By Knut Stolze in forum IBM DB2
    Replies: 0
    Last Post: August 6th, 07:55 AM
  5. Best practices for primary key (GUID VS Identity)
    By SamIAm in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 3rd, 02:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139