hi,

i am trying to insert data into sql server db using ado.net (vb.net) thru an
insert statement. I have a uniqueidentifier field in the table and asp.net
converts it to guid field and when i put guid.toString value in insert
statement

sql server exception occurs sayings cant convert string to uniqueidentifier

Re: converting string to uniqueidentifier by Miha

Miha
Fri Feb 18 02:07:46 CST 2005

Hi,

Instead you should really use parametrised statements.
Check out .net help on this.
It will be easier and more safe for you.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

"fahdj" <fahdj@discussions.microsoft.com> wrote in message
news:B82F55BB-3234-4358-ABB7-1233D6E90489@microsoft.com...
> hi,
>
> i am trying to insert data into sql server db using ado.net (vb.net) thru
> an
> insert statement. I have a uniqueidentifier field in the table and asp.net
> converts it to guid field and when i put guid.toString value in insert
> statement
>
> sql server exception occurs sayings cant convert string to
> uniqueidentifier



Re: converting string to uniqueidentifier by PL

PL
Fri Feb 18 09:21:32 CST 2005


There should be no problem to do this but make sure your query
is correctly formatted, including ' and ' around the guid you send in.

PL.

"fahdj" <fahdj@discussions.microsoft.com> skrev i meddelandet news:B82F55BB-3234-4358-ABB7-1233D6E90489@microsoft.com...
> hi,
>
> i am trying to insert data into sql server db using ado.net (vb.net) thru an
> insert statement. I have a uniqueidentifier field in the table and asp.net
> converts it to guid field and when i put guid.toString value in insert
> statement
>
> sql server exception occurs sayings cant convert string to uniqueidentifier



Re: converting string to uniqueidentifier by fahdj

fahdj
Fri Feb 18 18:59:02 CST 2005

i figuried it out. you have to do ..

"'{" & (new guid(str)).toString("D") & "}'"


its weird but u have to convert the string back to guid n thn nother string

"PL" wrote:

>
> There should be no problem to do this but make sure your query
> is correctly formatted, including ' and ' around the guid you send in.
>
> PL.
>
> "fahdj" <fahdj@discussions.microsoft.com> skrev i meddelandet news:B82F55BB-3234-4358-ABB7-1233D6E90489@microsoft.com...
> > hi,
> >
> > i am trying to insert data into sql server db using ado.net (vb.net) thru an
> > insert statement. I have a uniqueidentifier field in the table and asp.net
> > converts it to guid field and when i put guid.toString value in insert
> > statement
> >
> > sql server exception occurs sayings cant convert string to uniqueidentifier
>
>
>