PC Review


Reply
Thread Tools Rate Thread

Convert String Data Type to UniqueIdentifier data type

 
 
=?Utf-8?B?YW5n?=
Guest
Posts: n/a
 
      26th Jan 2004
Hi
I am facing this problem " specified cast is not valid" when I assgin a string data type into SqlDataAdapter's sql parameter
I would like to know how to convert string data type variable to UniqueIdentifier data type? Thank yo
Dim paraAppID As SqlParamete
paraAppID = cmd.Parameters.Add("@AppID", SqlDbType.UniqueIdentifier, 16, "AppID")
paraAppID.Direction = ParameterDirection.Inpu
paraAppID.Value = strAppID

Regard
ang
 
Reply With Quote
 
 
 
 
William Ryan
Guest
Posts: n/a
 
      26th Jan 2004
If I understand you correctly, why not just let the DB take care of this
for you?
"ang" <(E-Mail Removed)> wrote in message
news:4CCFE30B-E70A-414B-A9C6-(E-Mail Removed)...
> Hi,
> I am facing this problem " specified cast is not valid" when I assgin a

string data type into SqlDataAdapter's sql parameter.
> I would like to know how to convert string data type variable to

UniqueIdentifier data type? Thank you
> Dim paraAppID As SqlParameter
> paraAppID = cmd.Parameters.Add("@AppID",

SqlDbType.UniqueIdentifier, 16, "AppID")
> paraAppID.Direction = ParameterDirection.Input
> paraAppID.Value = strAppID
>
> Regard,
> ang



 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      26th Jan 2004
Hi,

You should use Guid data type instead of string.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"ang" <(E-Mail Removed)> wrote in message
news:4CCFE30B-E70A-414B-A9C6-(E-Mail Removed)...
> Hi,
> I am facing this problem " specified cast is not valid" when I assgin a

string data type into SqlDataAdapter's sql parameter.
> I would like to know how to convert string data type variable to

UniqueIdentifier data type? Thank you
> Dim paraAppID As SqlParameter
> paraAppID = cmd.Parameters.Add("@AppID",

SqlDbType.UniqueIdentifier, 16, "AppID")
> paraAppID.Direction = ParameterDirection.Input
> paraAppID.Value = strAppID
>
> Regard,
> ang



 
Reply With Quote
 
J Jones
Guest
Posts: n/a
 
      26th Jan 2004
Private Function StringToGuid(ByVal sValue As String) As System.Guid

Dim guidValue As System.Guid = _
CType(System.ComponentModel.TypeDescriptor.GetConverter( _
guidValue).ConvertFrom(sValue), System.Guid)
Return guidValue

End Function


 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      26th Jan 2004
Hi,

Dim g as new Guid(value) should be even easier
However, i suspect the original poster should not use strings at all...

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com


"J Jones" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Private Function StringToGuid(ByVal sValue As String) As System.Guid
>
> Dim guidValue As System.Guid = _
> CType(System.ComponentModel.TypeDescriptor.GetConverter( _
> guidValue).ConvertFrom(sValue), System.Guid)
> Return guidValue
>
> End Function
>
>



 
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
Convert a Number data type to a Text data type TKM Microsoft Access Queries 9 6th Nov 2008 09:59 PM
VBA Import Convert Data Type from Type 1 to Type 2 u473 Microsoft Excel Programming 3 21st Oct 2008 08:22 PM
VBA Data Type for SQL Server uniqueidentifier Type Don Microsoft Access Form Coding 9 17th Jan 2006 04:59 AM
VBA Data Type for SQL Server uniqueidentifier Type Don Microsoft Access External Data 9 17th Jan 2006 04:59 AM
How to convert a string value to a data type during runtime ? JC Voon Microsoft VB .NET 4 21st Jul 2005 02:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:16 AM.