代码如下:在点击按钮时进行修改操作
private void Button1_Click(object sender, System.EventArgs e)
{
int pdid=Convert.ToInt32(Request.QueryString["Infor"]);
Response.Write(pdid);
string strconn = "Initial Catalog=exam;Data Source=(local);user id=sa;password=";  
Response.Write(addzw.Text);
string strSQL2="update pdt set pcontent='" + addzw.Text + "',pdaan='"+zdaan.SelectedValue+"',pdifxs='"+ndxs.SelectedValue+"'where pdid='" + pdid + "'";
SqlConnection objcn1=new SqlConnection(strconn);
SqlCommand objcm2=new SqlCommand(strSQL2,objcn1);
SqlDataReader objr2=null;
//objr1.Close();
objcn1.Open();
objr2=objcm2.ExecuteReader(CommandBehavior.CloseConnection);
objr2.Close();
}
谢谢各位了

解决方案 »

  1.   

    string strSQL2="update pdt set pcontent='" + addzw.Text + "',pdaan='"+zdaan.SelectedValue+"',pdifxs='"+ndxs.SelectedValue+"'where pdid='" + pdid + "'";
    where 前面少了个空格
      

  2.   

    使用SqlCommand.ExecuteNonQuery 对连接执行 Transact-SQL 语句并返回受影响的行数。
      

  3.   

    其实这种错误很容易解决的,你跟踪一下程序,取得在程序中执行的SQL语言,然后copy 到sql server中执行一下,就可以知道那里出错了.
      

  4.   

    谢谢了,我想在问一下,除了sql语句我其他的语句对吗
      

  5.   

    就是如果我的sql语句是对的,可以修改吗