C#中更新数据库.mdb表格一条记录的完整代码怎么写啊,急求!

2024-12-19 16:41:10
推荐回答(1个)
回答1:

string ConnectionString = "Data Source=数据源;Database=数据库名称;uid=用户;Pwd=密码";
string sql = "update 数据表 set 字段1= '开',字段2='" + dt + "' (where +限定条件);
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
conn.Close();