110,576
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=IPAddress; initial catalog=DBName; User ID=sa; PWD=password";
con.Open();
SqlCommand cmd = new SqlCommand("", con);
cmd.CommandText = @"backup database DBName to disk='d:\bakfilename.bak'";
cmd.ExecuteNonQuery();
con.Close();
}
catch (SqlException ex)
{
throw ex;
}
}
OleDbConnection oleCnn = new OleDbConnection(你的数据库连接字符串);
oleCnn.Open();
OleDbCommand oleCmd = new OleDbCommand();
oleCmd.Connection = oleCnn;
oleCmd.CommandType = CommandType.StoredProcedure;
oleCmd.CommandText = "[你的存储过程]";
oleCmd.ExecuteNonQuery();