
Code
public static int UpdateOrInsert()
{
string strSQL=" insert into user_age (id,name,age) values(\'030\',\'wang\',24)";//要执行的insert或者Update语句
string strConnectionString="Data Source=10.0.3.25;Initial Catalog=user;User ID=sa;Password=123456";//数据库连接
int i = 0;
using (SqlConnection MySqlConn = new SqlConnection(strConnectionString))
{
MySqlConn.Open(); //打开数据库
try
{
SqlCommand com = new SqlCommand(strSQL, MySqlConn);
i = com.ExecuteNonQuery(); //执行操作
}
catch (Exception ex)
{
throw ex;
}
}
return i;
}
相关文章:
-
2021-09-02
-
2021-11-18
-
2021-11-18
-
2021-10-08
-
2021-12-27
-
2021-12-24
-
2021-11-18
-
2021-11-18
猜你喜欢
-
2021-11-18
-
2021-12-20
-
2022-02-13
-
2021-09-26
-
2022-12-23
-
2022-12-23
-
2021-12-15
相关资源
-
下载
2022-12-24
-
下载
2021-06-05
-
下载
2022-12-30