|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADODB GuidsI'm creating a program that uses the GUID as found in the database to
determine what information to display on the page. I pass in the guid though the url and then I was going to use it to query the database. strGuid = Request("Guid") strSQL = "SELECT * FROM Questions WHERE Key = ?" oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, adParamInput, 16, strGuid) I get an error "Application uses a value of the wrong type for the current operation." when I attempt to execute the statement. How can I query this using the parameters and passing in the Guid? I tried copying the guid to a byte array and had the same problem.
Show quote
"cfps.Christian" <ge0193***@otc.edu> wrote in message How is it formatted?news:09ed402f-8bd8-4d37-b5f9-b8104d900a52@e1g2000hsh.googlegroups.com... > I'm creating a program that uses the GUID as found in the database to > determine what information to display on the page. I pass in the guid > though the url and then I was going to use it to query the database. > > strGuid = Request("Guid") > strSQL = "SELECT * FROM Questions WHERE Key = ?" > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, > adParamInput, 16, strGuid) > > I get an error "Application uses a value of the wrong type for the > current operation." when I attempt to execute the statement. How can > I query this using the parameters and passing in the Guid? > > I tried copying the guid to a byte array and had the same problem. It should be a string with braces.... "{8CA3A28C-311D-4FEA-A30D-5A4BB71E7278}"
Show quote
On Nov 16, 1:45 pm, "Ralph" <nt_consultin***@yahoo.com> wrote: its formatted however I want it to be, I really haven't written the> "cfps.Christian" <ge0193***@otc.edu> wrote in message > > news:09ed402f-8bd8-4d37-b5f9-b8104d900a52@e1g2000hsh.googlegroups.com... > > > I'm creating a program that uses the GUID as found in the database to > > determine what information to display on the page. I pass in the guid > > though the url and then I was going to use it to query the database. > > > strGuid = Request("Guid") > > strSQL = "SELECT * FROM Questions WHERE Key = ?" > > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, > > adParamInput, 16, strGuid) > > > I get an error "Application uses a value of the wrong type for the > > current operation." when I attempt to execute the statement. How can > > I query this using the parameters and passing in the Guid? > > > I tried copying the guid to a byte array and had the same problem. > > How is it formatted? > It should be a string with braces.... > "{8CA3A28C-311D-4FEA-A30D-5A4BB71E7278}" code to input it yet
Show quote
"cfps.Christian" <ge0193***@otc.edu> wrote in message "adGuid" occasionally enforces expectations beyond our desires. <g>news:5c4588c4-5010-4a76-ba66-bd05e514f6ed@b36g2000hsa.googlegroups.com... > On Nov 16, 1:45 pm, "Ralph" <nt_consultin***@yahoo.com> wrote: > > "cfps.Christian" <ge0193***@otc.edu> wrote in message > > > > news:09ed402f-8bd8-4d37-b5f9-b8104d900a52@e1g2000hsh.googlegroups.com... > > > > > I'm creating a program that uses the GUID as found in the database to > > > determine what information to display on the page. I pass in the guid > > > though the url and then I was going to use it to query the database. > > > > > strGuid = Request("Guid") > > > strSQL = "SELECT * FROM Questions WHERE Key = ?" > > > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, > > > adParamInput, 16, strGuid) > > > > > I get an error "Application uses a value of the wrong type for the > > > current operation." when I attempt to execute the statement. How can > > > I query this using the parameters and passing in the Guid? > > > > > I tried copying the guid to a byte array and had the same problem. > > > > How is it formatted? > > It should be a string with braces.... > > "{8CA3A28C-311D-4FEA-A30D-5A4BB71E7278}" > > its formatted however I want it to be, I really haven't written the > code to input it yet -ralph "cfps.Christian" <ge0193***@otc.edu> wrote in message Try dropping the size:news:09ed402f-8bd8-4d37-b5f9-b8104d900a52@e1g2000hsh.googlegroups.com... > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, > adParamInput, 16, strGuid) oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid, adParamInput, , strGuid) For those that read this later I solved my problem by cheating.
In my Select statement where I put the parameter that was the guid I simply put Cast(? AS UniqueIdentifier) and passed in the variable as a varchar. oCMD.Parameters.Append oCMD.CreateParameter("@Key", adVarchar, adParamInput, 40, strGuid) "cfps.Christian" <ge0193***@otc.edu> wrote in message For those that read this later, I don't think that is cheating at all. :)news:de3fbdba-204f-46e4-adb5-e3d02583da40@e4g2000hsg.googlegroups.com... > For those that read this later I solved my problem by cheating. > > In my Select statement where I put the parameter that was the guid I > simply put Cast(? AS UniqueIdentifier) and passed in the variable as a > varchar. > > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adVarchar, > adParamInput, 40, strGuid) You are starting with a string containing a Guid. Passing that along, and converting it at the point it needs to be converted, makes perfect sense, and avoids the possibly awkward business of passing a real Guid as a SQL parameter. Strings are a good safe territory for this sort of thing.
Show quote
"Steve Gerrard" <mynameh***@comcast.net> wrote in message I don't disagree, but would like to add ...news:5tWdnXGWkLdcA9banZ2dnUVZ_rGrnZ2d@comcast.com... > > "cfps.Christian" <ge0193***@otc.edu> wrote in message > news:de3fbdba-204f-46e4-adb5-e3d02583da40@e4g2000hsg.googlegroups.com... > > For those that read this later I solved my problem by cheating. > > > > In my Select statement where I put the parameter that was the guid I > > simply put Cast(? AS UniqueIdentifier) and passed in the variable as a > > varchar. > > > > oCMD.Parameters.Append oCMD.CreateParameter("@Key", adVarchar, > > adParamInput, 40, strGuid) > > For those that read this later, I don't think that is cheating at all. :) > > You are starting with a string containing a Guid. Passing that along, and > converting it at the point it needs to be converted, makes perfect sense, and > avoids the possibly awkward business of passing a real Guid as a SQL parameter. > Strings are a good safe territory for this sort of thing. > The "cheat" part would be calling it a GUID and managing it as String. I didn't respond to the User's last post because you will noticed he now calls it a "UniqueIdentifier". I have seen multiple-developer projects run into trouble when developers confuse the two with any database or library that supports a GUID as a separate datatype. The GUID datatype is anologous to a DATE/TIME datatype - in that the presentation is separate from the actual internal representation. Much of the time you can make safe assumptions and all will come out well, but occasionally it will bite you. Just as it did in the OP. <g> -ralph |
|||||||||||||||||||||||