在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/// 附加数据库 /// </summary> /// <returns></returns> private bool Attachdb() { try { string sql = string.Empty; if (File.Exists(sMDBFile)) { sql = "EXEC sp_attach_db @dbname = '" + txtDBName.Text + "', @filename1 = '" + sMDBFile+ "',@filename2='" + sLog + "'"; SqlConnection conn = new SqlConnection(string.Format("Data Source={0};Initial Catalog=master;User ID={1};PWD={2}","(local)","sa","pwd")); using (conn) { lock (conn) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); } } } return true; } catch { return false; } } //sMDBFile 为mdf文件路径 //sLog 为ldf文件路径 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论