将登陆界面控件的值Login1.username付给查询语句,但是出错了。
string strcommand="select * from t1 where name_id = 'Login1.username'";

解决方案 »

  1.   

    string strcommand="select * from t1 where name_id = "+Login1.username;
      

  2.   

    不行啊,用textbox1.text 也不行
    string strcommand="select * from t1 where name_id = "+textbox1.text ;这样也不行啊!!
    string strcommand="select * from t1 where name_id = 'textbox1.text'" ;
      

  3.   

    string strcommand="select * from t1 where name_id = '"+textbox1.text+"'" ;
    到底是不是你的SQL语句的问题哦。
      

  4.   

    直接赋值可以:
    string strcommand="select * from t1 where name_id = ‘aa’“ ;
    这样不行
    string strcommand="select * from t1 where name_id = "+textbox1.text ;
      

  5.   

    我想问一下,你的登陆界面是用什么软件开发的,是Microsoft Visual Studio 弄的吗???
      

  6.   

    '"+text1.text+"'
    '+text1.text+'
    "+text1.text+"
    都不行啊,是格式的问题哦,到底应该怎么写哦。
      

  7.   

    string strcommand="select * from t1 where name_id = '"+textbox1.text +"'";
      

  8.   

    string strcommand="select * from t1 where name_id = '{0}'";
    strcommand=string.Format(strcommand,textbox1.text);
      

  9.   

    string strcommand="select * from t1 where name_id = '{0}'";
    strcommand=string.Format(strcommand,textbox1.text);
    这个行!!
      

  10.   

    string strcommand="select * from t1 where name_id = '{0}'";
    strcommand=string.Format(strcommand,textbox1.text);
    我想问下{0}代表啥意思??