求助啊啊 !!大神们

wk836119465 2013-06-07 10:30:40
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
...全文
96 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wk836119465 2013-06-07
  • 打赏
  • 举报
回复
string sql = "select @a=pwd from pwd where num='" + textBox1.Text + "'";这句学错了应该是string sql = "select pwd from pwd where num='" + textBox1.Text + "'";
wk836119465 2013-06-07
  • 打赏
  • 举报
回复
pow表里面的pow名字一样而已
threenewbee 2013-06-07
  • 打赏
  • 举报
回复
如果你的表叫"pwd"的话,如果不是这样,from后面写表名。
threenewbee 2013-06-07
  • 打赏
  • 举报
回复
string sql = "select pwd from pwd where num='" + textBox1.Text + "'";
threenewbee 2013-06-07
  • 打赏
  • 举报
回复
sql = "select @a=pwd from pwd where num='" + textBox1.Text + "'"; =〉 sql = "update from pwd set @a=pwd where num='" + textBox1.Text + "'";

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧