visual 中sqlcommand 对象中ExecuteNonQuery和Connection两个属性的用法

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:47:05

ExecuteNonQuery 一般是执行非查询语句.并返回影响行数的.
Connection 是sqlcommand所使用的sqlconnection对象.

用法:

string sql="update TableName set a='1000'";
SqlConnection con=new SqlConnection("你的链接字符串");
SqlCommand com=new SqlCommand(sql);
com.Connection=con;//设置它的connection对象;
int result=com.ExecuteNonQuery();//执行并返回影响行数