Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error converting data type varchar to uniqueidentifier

Status
Not open for further replies.

fr2

Programmer
May 13, 2008
45
US
There is SQL Server stored procedure with one of the input parameters a uniqueidentifier ...

I tested the sp in SQL Server itself and it works fine ..
However from ASP.NET code when tring to use the sp .. I get the error

Error converting data type varchar to uniqueidentifier

How do I pass the uniqueidentifier (userID) value .. I tried varchar .. but no luck it seems

mDbConn = New SqlConnection(ConnectionString)
mDbConn.Open()

mSqlCmd = New SqlCommand("usp_GetMYsp", mDbConn)
mSqlCmd.CommandType =Data.CommandType.StoredProcedure

mSqlCmd.Parameters.Add("@userID", Data.SqlDbType.VarChar)
mSqlCmd.Parameters("@userID").Value = myVal.ToSTring

mSqlCmd.Parameters.Add("@Field2", Data.SqlDbType.Int)
mSqlCmd.Parameters("@Field2").Value = intEventUserEventRoleID

mSqlDr = mSqlCmd.ExecuteReader()
 
try:
Code:
mSqlCmd.Parameters.Add("@userID", Data.SqlDbType.[red]UniqueIdentifier[/red])
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top