PC Review


Reply
Thread Tools Rate Thread

converting string to uniqueidentifier

 
 
=?Utf-8?B?ZmFoZGo=?=
Guest
Posts: n/a
 
      18th Feb 2005
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
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      18th Feb 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" <(E-Mail Removed)> wrote in message
news:B82F55BB-3234-4358-ABB7-(E-Mail Removed)...
> 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



 
Reply With Quote
 
PL
Guest
Posts: n/a
 
      18th Feb 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" <(E-Mail Removed)> skrev i meddelandet news:B82F55BB-3234-4358-ABB7-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?ZmFoZGo=?=
Guest
Posts: n/a
 
      19th Feb 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" <(E-Mail Removed)> skrev i meddelandet news:B82F55BB-3234-4358-ABB7-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion failed when converting from a character string to uniqueidentifier. Allen Moss Microsoft ADO .NET 0 15th Feb 2006 02:31 PM
Getting Syntax error converting from a character string to uniqueidentifier Roy Rodsson via .NET 247 Microsoft VB .NET 2 23rd Apr 2004 10:33 AM
convert string variable to uniqueidentifier =?Utf-8?B?U2FuZHk=?= Microsoft VB .NET 6 25th Feb 2004 03:56 PM
converting String to uniqueidentifier =?Utf-8?B?U2FuZHJh?= Microsoft C# .NET 1 25th Feb 2004 01:42 AM
RE: Syntax error converting from a character string to uniqueidentifier Scot Rose [MSFT] Microsoft ADO .NET 0 31st Jul 2003 04:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 AM.