0

ERROR :

System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.


I made a admin side for editing roles and user passwords if necessary.. But since the default ASPNETDB,mdf have UserID and Password in 'Unique Identifier' data type.. while I try to update the User fields from admin side (used a grid to bring complete table :p)
It gives me above error...

Help is required soon pls.. where am I missing anything ?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by blackdragon1027
1

you can use the sqlcommand.parameters.addwithvalue("@yourParameterName", yourValue) which should be efficiënt enough to update the values... for example:

string sql = "UPDATE aspnet_Membership SET Password = @NewPassword WHERE UserId=@UserId AND ApplicationId=@ApplicationId"
oCom.CommandText=sql;
oCom.Parameters.AddWithValue("@UserId", yourUserIdValue);
oCom.Parameters.AddWithValue("@ApplicationId", "yourApplicationId");
object retVal = null;
retVal = oCom.ExecuteScalar();
if(retVal != null & retVal > -1)
  // do something with the returnvalue

Be aware that the membership api has some features for this also :)
Besides this, you should use the salt/hash (if specified in the web.config) to scamble the password. In thát case you should also update the passwordsalt concerning the passwordformat in the DB. Check both stored procedures "[aspnet_Membership_SetPassword]" and [aspnet_Membership_ResetPassword] which fields they use....

Regards,
Richard
The Netherlands

Edited by 4advanced: n/a

Votes + Comments
Thanks for clearing things a bit, will try with it and tell you if i face any problem.. once again Thanks to you.. Have A Nice Day.
0

I don't understand you well.
I suppose you are going to use the default SQL DB to manage the user mode.
If so, it is not necessary to write your own code.
YOu can use the .NET Membership provider.
Looking forward to your success . . .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.