怎么回事啊? 错误 1 无法将文件“E:\赵敏\c#源代码\myProject\学生管理系统\学生管理系统\database\studentManage.ldf”复制到“bin\Debug\database\studentManage.ldf”。文件“E:\赵敏\c#源代码\myProject\学生管理系统\学生管理系统\database\studentManage.ldf”正由另一进程使用,因此该进程无法访问该文件。 学生管理系统 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你项目里的studentManage.ldf文件正在被使用而你对这个文件的属性是“始终复制”所以编译器尝试将这个文件复制到调试目录bin\Debug\下的时候无法继续进行要么你吧studentManage.ldf的使用关闭,或者吧属性改为“如果较新则复制”应该就好了 if (this.txtUser.Text == "") { MessageBox.Show("用户名不能为空!"); this.txtUser.Focus(); return; } else { if (this.txtPwd.Text == "") { MessageBox.Show("密码 不能为空!"); this.txtPwd.Focus(); return; } else { SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=studentManage;Integrated Security=True"); string sql="select * from operator where Op_user='"+this.txtUser.Text.ToString()+"'"; SqlDataAdapter da = new SqlDataAdapter(sql,con); DataSet ds = new DataSet(); try { da.Fill(ds, "operator"); } catch (Exception) { MessageBox.Show("数据库未能成功连接"); } if (ds.Tables["operator"].Rows[0][0].ToString()==this.txtPwd.Text.Trim()) { user_name = ds.Tables[0].Rows[0][2].ToString(); user_level = ds.Tables[0].Rows[0][4].ToString(); this.Hide(); Main_info mi = new Main_info(); mi.Show(); } else { MessageBox.Show("用户名和密码输入错误!!!"); this.txtPwd.Text=this.txtUser.Text=""; this.txtUser.Focus(); return; } } }这是代码 ctrl+alt+delete把启动的线程停掉 在进程里 把所有 sql模样的进程关闭就OK 了 昨天我才碰到过 关闭SQL Server的服务管理器,然后把database文件夹复制到其他地方然后重新附加就可以了,但是不知道是为什么 与sql的连接未关闭吧?处于连接状态sql服务器当然不会让你复制了 因為DB文件被使用中... ... Attach上去就不能覆蓋了,把SQL服務停用就可以了 js 调用CS的方法 C# 问串口问题() 对DataGridView中选中的一些行进行删除,同时在数据库中删除记录 关于SQL SERVER2000的问题 一个关于力图形的问题哈 VS2005问题 如何捕获DataAdapter.Update()执行时的SQL语句,以便记录到日志文件? 为什么c#不能运行???大家帮忙看看 就是用C#创建一个DataTable,如何写呀????? 请教一个莫名其妙的问题 如何改变imagesize DEV控件gridcontrol的验证gridview的内容验证
而你对这个文件的属性是“始终复制”
所以编译器尝试将这个文件复制到调试目录bin\Debug\下的时候无法继续进行要么你吧studentManage.ldf的使用关闭,或者吧属性改为“如果较新则复制”
应该就好了
if (this.txtUser.Text == "")
{
MessageBox.Show("用户名不能为空!");
this.txtUser.Focus();
return;
}
else
{
if (this.txtPwd.Text == "")
{
MessageBox.Show("密码 不能为空!");
this.txtPwd.Focus();
return;
}
else
{
SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=studentManage;Integrated Security=True");
string sql="select * from operator where Op_user='"+this.txtUser.Text.ToString()+"'";
SqlDataAdapter da = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
try
{
da.Fill(ds, "operator"); }
catch (Exception)
{
MessageBox.Show("数据库未能成功连接");
}
if (ds.Tables["operator"].Rows[0][0].ToString()==this.txtPwd.Text.Trim())
{
user_name = ds.Tables[0].Rows[0][2].ToString();
user_level = ds.Tables[0].Rows[0][4].ToString();
this.Hide();
Main_info mi = new Main_info();
mi.Show();
}
else
{
MessageBox.Show("用户名和密码输入错误!!!");
this.txtPwd.Text=this.txtUser.Text="";
this.txtUser.Focus();
return;
}
}
}
这是代码