I
Igor
Hi
I have a drop down list on my page that lists some items returned from a
database. Each item has its GUID (or uniqueidentifier). I have to (in code
behind of the page) read this GUID, to hand it over to a query (stored
procedure) that takes the GUID and looks for some data in a specific table.
I don't know have to hand it to the query as GUID.
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "dbo.tbh_GetBoundIdentifier";
myCommand.CommandType = CommandType.StoredProcedure;
string BoundID =
DropDownList4.SelectedItem.Value.ToString();
SqlParameter myParameter1 = new SqlParameter();
myParameter1.ParameterName = "@BoundID";
myParameter1.SqlDbType = SqlDbType.UniqueIdentifier;
myParameter1.Value = BoundID;
SqlParameter myParameter2 = new SqlParameter();
myParameter2.ParameterName = "@BoundIdentifier";
myParameter2.SqlDbType = SqlDbType.Char;
myParameter2.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(myParameter1);
myCommand.Parameters.Add(myParameter2);
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
WIth the code above I get the following error: "Failed to convert parameter
value from a String to a Guid" when trying to execute the command
myCommand.ExecuteReader();. How can I handle (or convert) the GUID so it is
handed as GUID and not as a string?
I have a drop down list on my page that lists some items returned from a
database. Each item has its GUID (or uniqueidentifier). I have to (in code
behind of the page) read this GUID, to hand it over to a query (stored
procedure) that takes the GUID and looks for some data in a specific table.
I don't know have to hand it to the query as GUID.
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "dbo.tbh_GetBoundIdentifier";
myCommand.CommandType = CommandType.StoredProcedure;
string BoundID =
DropDownList4.SelectedItem.Value.ToString();
SqlParameter myParameter1 = new SqlParameter();
myParameter1.ParameterName = "@BoundID";
myParameter1.SqlDbType = SqlDbType.UniqueIdentifier;
myParameter1.Value = BoundID;
SqlParameter myParameter2 = new SqlParameter();
myParameter2.ParameterName = "@BoundIdentifier";
myParameter2.SqlDbType = SqlDbType.Char;
myParameter2.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(myParameter1);
myCommand.Parameters.Add(myParameter2);
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
WIth the code above I get the following error: "Failed to convert parameter
value from a String to a Guid" when trying to execute the command
myCommand.ExecuteReader();. How can I handle (or convert) the GUID so it is
handed as GUID and not as a string?