有关C#备份错误问题 120
if(textBox1.Text==""||textBox2.Text==""){MessageBox.Show("输入不完整,请检查输入!","提示",MessageB...
if (textBox1.Text == "" || textBox2.Text =="")
{
MessageBox.Show("输入不完整,请检查输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
string connString = @"Data Source=.\SQLEXPRESS;Initial Catalog=AAA;Integrated Security=True";
SqlConnection connection = new SqlConnection(connString);
try
{
connection.Open();
string sql = @"backup database " + textBox1.Text + " TO disk='" + textBox2.Text + "'";
SqlCommand command = new SqlCommand(sql,connection );
int count = command.ExecuteNonQuery ();
if (count > 0)
{
MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("备份失败!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message , "信息提示", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
connection.Close();
}
一直不能成功,问题在哪里,怎么改? 展开
{
MessageBox.Show("输入不完整,请检查输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
string connString = @"Data Source=.\SQLEXPRESS;Initial Catalog=AAA;Integrated Security=True";
SqlConnection connection = new SqlConnection(connString);
try
{
connection.Open();
string sql = @"backup database " + textBox1.Text + " TO disk='" + textBox2.Text + "'";
SqlCommand command = new SqlCommand(sql,connection );
int count = command.ExecuteNonQuery ();
if (count > 0)
{
MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("备份失败!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message , "信息提示", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
connection.Close();
}
一直不能成功,问题在哪里,怎么改? 展开
2个回答
2010-12-15
展开全部
jzxhcmn
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询