大疆电池:SQL语句求教

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 12:32:17
strsql="select * from users where User_id='"+Tbx_userid.Text+"'and
User_password='"+Tbx_userpwd.Text+"'";

请教这个SQL语句中"+Tbx_userid.Text+"的“+”号是干什么用的?起哦在很多SQL语句中都见过这种情况。

+和&的功能相同,起字符串连接的作用,通常用来连接一个字符串变量和一个字符串,比如:
字符串变量:str="string1"
字符串:"string2"
那么:
"string2"+str = "string2string1"
同理:
strsql="select * from users where User_id='"+Tbx_userid.Text+"'and User_password='"+Tbx_userpwd.Text+"'"
当Tbx_userid.Text="1001",Tbx_userpwd.Text="pwd"时,那么,连接后的字符串为:
"select * from users where User_id='1001' and User_password='pwd'"

这个+只是一个运算符,在SQL语句中等同&

strsql="select * from users where User_id='"&Tbx_userid.Text&"'and
User_password='"&Tbx_userpwd.Text&"'";