Home > Net >  In c # to do the registration of "English" username varchar unable to convert an int, boss
In c # to do the registration of "English" username varchar unable to convert an int, boss

Time:09-19

Doing the registration of "English" username varchar cannot convert int
System. The Data. SqlClient. SqlException: "in a varchar value 'asdxzc' failure when converted to Data type int,"
Code:
SqlCommand CMD=new SqlCommand (@ "select userId from the userInfo where userId='" + Text_Name. Text +"' ", conn);//in the database to find the userName name field data in the table
conn.Open();
String Flag=the Convert. ToString (CMD) ExecuteScalar ());

CodePudding user response:

Field to write the wrong ah, look at your SQL, look at what you want to check again,

CodePudding user response:

reference 1/X - I - n reply:
field to write the wrong ah, look at your SQL, to look up, look back to see you again

, poke, eye,

CodePudding user response:

Check out the code will be displayed or implicit conversion,,,

CodePudding user response:

You select statement to write the query userId field (the integer field?) You to pass parameters: asdxzc is a string

CodePudding user response:

In addition, in the practical work of your this kind of writing is not a security scan (because it carries the risk of SQL injection), so please use the
 SELECT userId FROM the userInfo WHERE userName=@ userName 

In addition, you of the login problems appear to have inspection (due to unclear your bad comments to specific motivation),

CodePudding user response:

reference 5 floor hook wujiang south reply:
in addition, in the practical work of your this kind of writing is not a security scan (because it carries the risk of SQL injection), so please use the
 SELECT userId FROM the userInfo WHERE userName=@ userName 

In addition, you of the login problems appear to have inspection (due to not clear your bad comments to specific motivation),

Now still a student, but also in learning, learn behind is sure to teach
  •  Tags:  
  • C#