using (SqlConnection cn = new SqlConnection())
{
cn.ConnectionString = cnn
cn.Open()
SqlCommand cmd = new SqlCommand()
cmd.Connection = cn
cmd.CommandText = "update table set field='"+ 你的变量+"' where id="+更新条件
cmd.ExecuteNonQuery()//执行更新
}
看一下这样行不SqlConnection Conn = new SqlConnection("server=localhostuid=sapwd=database=ddb")
SqlDataAdapter da = new SqlDataAdapter("select *from book",con)
DataSet ds = new DataSet()
da.Fill(ds,"book")
SqlCommand updateCmd = new SqlCommand("Update book set bookname='javascript'",Conn)
da.UpdateCommand=updateCmd
da.Update(ds)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)