请问如何更改数据库路径?
请问如何更改数据库路径?private string connectionstring=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+"\\student\\student\\student.mdb;";
可以把连接字符串存到 .ini文件中 然后用 system.io 下的 file 打开 ini 把里面的字符串 赋给你定义的 连接字符串
string StrConn = "";
string Path = @"c:\oledb.ini";
string StrCom = "insert into d (a,b,c) values ('" + txta.Text + "','" + txtb.Text + "','" + txtc.Text + "')";
using (StreamReader FileOpen = File.OpenText(Path))
{
StrConn = FileOpen.ReadLine();
}
OleDbConnection oConn = new OleDbConnection(StrConn);
OleDbCommand oCom = new OleDbCommand(StrCom,oConn);
oConn.Open();
oCom.ExecuteNonQuery();
oConn.Close();