Problem with GUID's

P

PatLaf

Hello all,
I have an application that reads guids from sql server
and stores them as the value in a drop down list. Once
they are stored as strings I can't figure out how to get
it back to a guid type for the sql server's sproc. I keep
getting an invalid cast from string.....type string
cannot be converted to guid. The problem is that I need
the string converted back to guid so that I can qry the
db using the guid. Any ideas would be greatly appreciated.


Thanks in advance
Pat
 
M

M K

Try something like this:
cmdPhtgUpd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PaymentMethods", System.Data.SqlDbType.UniqueIdentifier, 254, "PaymentMethods"))
 
K

Kathleen Dollard

Pat,

Try using the GUID constructor

Dim g As System.Guid
g = New System.Guid(stringGUID)

Kathleen
 
K

Kevin Yu [MSFT]

Hi PatLaf,

When you're binding a drop down list to a Guid column, you needn't convert
it to string. Just set the data source and data member, the Guid will be
converted to string automatically.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top