日期:2014-05-17  浏览次数:20753 次

求助啊啊 !!大神们
 private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=Tesk;Integrated Security=True";

            conn.Open();;
            string sql = "select @a=pwd from pwd where num='" + textBox1.Text + "'";
            SqlCommand sqlCommand = new SqlCommand(sql, conn);
            sqlCommand.CommandType = CommandType.Text;
            conn.Open();
            string a = sqlCommand.ExecuteScalar();最后一句错了,我只想把pwd的值赋值给a

------解决方案--------------------
sql = "select @a=pwd from pwd where num='" + textBox1.Text + "'";
=〉
sql = "update from pwd set @a=pwd where num='" + textBox1.Text + "'";