Click here to Skip to main content
15,891,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i used asp c#

SqlParameter[] paramdizi2 = new SqlParameter[3]
            {                
                new SqlParameter("@UserId",SqlDbType.UniqueIdentifier),  
                new SqlParameter("@RolId",SqlDbType.UniqueIdentifier),
                new SqlParameter("@Sonuc",SqlDbType.Int) 
                                  
            };
            paramdizi2[0].Value = TxtUserId.Text;
            paramdizi2[1].Value = TxtRolId.Text;
            paramdizi2[2].Direction = ParameterDirection.ReturnValue;
            baglan.ExecuteNonQuery("RolDuzenle", CommandType.StoredProcedure, paramdizi2);


Failed to convert parameter value from string to guid.

How can I do this?
Posted
Updated 13-Jun-11 1:06am
v2
Comments
Dalek Dave 13-Jun-11 7:06am    
Edited for Grammar, Syntax, Readability and Code Block.

you are trying to insert string value to a GUID field of your database.

Check your code and insert a valid GUID into the UniqueIdentifier field.

check if @userid and @roleid both are of type uniqueidentifier...

you may catch error by trying above points :)
 
Share this answer
 
Try to convert string to GUID before assigning:
paramdizi2[0].Value = New Guid(TxtUserId.Text);
 
Share this answer
 
Comments
Dalek Dave 13-Jun-11 7:07am    
Good Call.
RakeshMeena 13-Jun-11 7:10am    
Thanks Dalek!
Ccsnow 13-Jun-11 7:24am    
thank you from Turkey
RakeshMeena 13-Jun-11 7:27am    
Welcome from India!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900