关于C#数据库附加的
string DbPath=System.Environment.CurrentDirectory +@"\DabaBase\supmark_Data.MDF"; string LogPath=System.Environment.CurrentDirectory +@"\DabaBase\supmark_Log.LDF";
string StrSql="exec sp_attach_db @dbname='supmark',@filename1='"+DbPath+"',@filename2='"+LogPath+"'";
string strcon="Server=(local);Integrated Security=SSPI;Database=master";
try
{
SqlConnection objcn=new SqlConnection(strcon);
SqlCommand cmd =new SqlCommand (StrSql,objcn);
objcn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("附加成功");
cmd.Dispose();
objcn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
附加的时候提示,设备激活错误。不知道该怎么解决