c#相对路径,链接Access数据库
OleDbConnectionconn=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c...
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/jxy/xh.mdb");
conn.Open();
OleDbCommand cmd1 = new OleDbCommand("select count(*) from teacher ", conn);
yy = (int)cmd1.ExecuteScalar();
OleDbCommand cmd = new OleDbCommand("delete from sjs ", conn);
// SqlCommand cmd = new SqlCommand("delete sjs ", conn);
cmd.ExecuteNonQuery();
conn.Close();
button2.Enabled = true;
button3.Enabled = false;
如上代码改如何改写。。我自己改后总是提示找不到文件,放到bin/Debug 也不行,急求前辈解答~! 展开
conn.Open();
OleDbCommand cmd1 = new OleDbCommand("select count(*) from teacher ", conn);
yy = (int)cmd1.ExecuteScalar();
OleDbCommand cmd = new OleDbCommand("delete from sjs ", conn);
// SqlCommand cmd = new SqlCommand("delete sjs ", conn);
cmd.ExecuteNonQuery();
conn.Close();
button2.Enabled = true;
button3.Enabled = false;
如上代码改如何改写。。我自己改后总是提示找不到文件,放到bin/Debug 也不行,急求前辈解答~! 展开
1个回答
展开全部
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\jxy\xh.mdb");
或者
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\jxy\\xh.mdb");
更多追问追答
追问
你这跟我的有什么区别吗
追答
表示文件路径你用的是 "/",应该用"\"
还有:如果按这样写,你的数据文件必须放置在文件夹 C:\jxy\下!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询