- 积分
- 1
- 在线时间
- 21 小时
- 主题
- 3
- 注册时间
- 2014-5-13
- 帖子
- 25
- 最后登录
- 2015-3-12
- 帖子
- 25
- 软币
- 208
- 在线时间
- 21 小时
- 注册时间
- 2014-5-13
|
楼主 |
发表于 2014-5-21 13:31:17
|
显示全部楼层
string sqlstr = "use AIS20130903115228 ---------一定要在此手工输入你的账套实体名\r\n"
+"declare @dbname varchar(255)\r\n"
+"set @dbname='AIS20130903115228' "
+"ALTER DATABASE AIS20130903115228 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;\r\n"
+"dbcc checktable('t_voucherentry',REPAIR_ALLOW_DATA_LOSS)\r\n"
+"dbcc checktable('t_voucherentry',REPAIR_REBUILD)\r\n"
+"ALTER DATABASE AIS20130903115228 SET MULTI_USER;";
var conn = new SqlConnection("Data Source=192.168.91.210\\SQL2012;Initial Catalog=AIS20130903115228;Persist Security Info=True;User ID=sa;Password=321456");
conn.InfoMessage += new SqlInfoMessageEventHandler(conn_InfoMessage);
//为其绑定事件
using (var cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandText = sqlstr;
int row=cmd.ExecuteNonQuery();
conn.Close();
}
void conn_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
MessageBox.Show(e.Message);
}
|
|