110,539
社区成员
发帖
与我相关
我的任务
分享
.............
public static int getcom(string comstr)
{
........................
return i; //i是返回的受影响的行数
}
try
{
int isupdateok=mybase.getcom("update sb set jfbj='是',jfrq='" + System.DateTime.Now.ToShortDateString().ToString() + "'where " + dwsb + "='" + this.textBox7.Text.Trim() + "'and nf='" + this.numericUpDown4.Value.ToString().Trim() + "'and yf='" + this.numericUpDown3.Value.ToString().Trim() + "' ");
//就是上面的更新语句影响的行数大于0就认为更新成功了,否则是没有更新或更新失败
if(isupdateok>0)
{
MessageBox.Show("更新成功");
}
else
{
MessageBox.Show("更新失败!");
}
}
catch
{
MessageBox.Show("更新失败");
}
private static void CreateCommand(string queryString,
string connectionString)
{
using (SqlConnection connection = new SqlConnection(
connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}