-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqlDataUpdate.cs
More file actions
23 lines (22 loc) · 985 Bytes
/
Copy pathSqlDataUpdate.cs
File metadata and controls
23 lines (22 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System.Data.SqlClient;
namespace HomeWorkSQL
{
class SqlDataUpdate
{
public void sqlDataUpdate(int id ,string name, string birthday, string job, bool marry)
{
SQLconnect connection = new SQLconnect();
SqlConnection conn = connection.getConnection();
SqlCommand sqlAddCommand = new SqlCommand();
conn.Open();
sqlAddCommand.Connection = conn;
sqlAddCommand.CommandText = $"Update AccountInfo set ID = @id ,Name = @name,Birthday = @birthday,Job = @job,Marry = @marry WHERE ID = {id}";
sqlAddCommand.Parameters.AddWithValue("@id", id);
sqlAddCommand.Parameters.AddWithValue("@name", name);
sqlAddCommand.Parameters.AddWithValue("@birthday", birthday);
sqlAddCommand.Parameters.AddWithValue("@job", job);
sqlAddCommand.Parameters.AddWithValue("@marry", marry);
sqlAddCommand.ExecuteNonQuery();
}
}
}