string strconn = "server = (local);database = dongmu;Trusted_Connection=yes";
                try
                {
                    SqlConnection conn = new SqlConnection(strconn);
                    conn.Open();   
                    string sql = "select * from user where name='"+this.textBox3.Text.Trim()+"'and pwd='"+this.textBox4.Text.Trim()+"'";
                    SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    if (ds.Tables[0].Rows[0]["name"].ToString() == this.textBox3.Text.Trim())
                    {
                        form2 = new Form2();
                        form2.Visible = true;
                    }
                    conn.Close();
                }
                catch (Exception g)
                {
                    MessageBox.Show(g.Message);
                }
错误报告:user附近有语法错误,希望高手指点一下!

解决方案 »

  1.   

    user name 都是系统定义过的 最好这样写[user]
      

  2.   

    将select * from user where name='"+this.textBox3.Text.Trim()+"'and pwd='"+this.textBox4.Text.Trim()+"'";形成真正的sql语句拷贝到查询分析器中执行一下就知道错误原因啦
      

  3.   

    试试这个:
    string sql = "select * from [user] where [name]='"+this.textBox3.Text.Trim()+"' and pwd='"+this.textBox4.Text.Trim()+"'";