Home All Groups Group Topic Archive Search About
Author
16 Nov 2007 7:26 PM
cfps.Christian
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.

Author
16 Nov 2007 7:45 PM
Ralph
Show quote
"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}"
Author
16 Nov 2007 8:44 PM
cfps.Christian
Show quote
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
Author
16 Nov 2007 8:56 PM
Ralph
Show quote
"cfps.Christian" <ge0193***@otc.edu> wrote in message
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

"adGuid" occasionally enforces expectations beyond our desires. <g>

-ralph
Author
16 Nov 2007 10:03 PM
Jeff Johnson
"cfps.Christian" <ge0193***@otc.edu> wrote in message
news:09ed402f-8bd8-4d37-b5f9-b8104d900a52@e1g2000hsh.googlegroups.com...

> oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid,
> adParamInput, 16, strGuid)

Try dropping the size:

oCMD.Parameters.Append oCMD.CreateParameter("@Key", adGuid,
    adParamInput, , strGuid)
Author
26 Nov 2007 6:17 PM
cfps.Christian
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)
Author
27 Nov 2007 4:36 AM
Steve Gerrard
"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.
Author
27 Nov 2007 2:28 PM
Ralph
Show quote
"Steve Gerrard" <mynameh***@comcast.net> wrote in message
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.
>

I don't disagree, but would like to add ...
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

AddThis Social Bookmark Button