//Retrieve data to display
string queryString2 = "SELECT [ConfidenceLevel], [LoveLevel], [StressLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID) ORDER BY [DateTime] ASC";
SqlCommand CommandSelect = new SqlCommand(queryString2, database.Connection);
//add parameters. used to prevent sql injection
CommandSelect.Parameters.Add("@UserProfileID", SqlDbType.UniqueIdentifier);
CommandSelect.Parameters["@UserProfileID"].Value = Membership.GetUser().ProviderUserKey;
So at the very end, instead of using the “Membership.GetUser().ProviderUserKey” I want to use a dynamic member ID, that I will only have available as a string from the GET name value pair.
i.e. – string id = “a051fc1b-4f51-485b-a07d-0f378528974e “
How do I get this string to be assigned to the last SQL parameter line assigning the value? Type cast it?
If I just assign it the string I recieve the error:
Invalid cast from ‘System.String’ to
‘System.Guid’.
Thank You.
1 Answer