asp.net中连接Access数据库可以用"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("DataBa/[email protected]");我想问的是在windows窗体中怎么写数据库的相对路径????
System.Web.HttpContext.Current.Server.MapPath("DataBa/[email protected]");这个在Windows窗体中不能用!!
System.Web.HttpContext.Current.Server.MapPath("DataBa/[email protected]");这个在Windows窗体中不能用!!
解决方案 »
- 在非web环境下使用Server.UrlDecode
- MSDN中 ienumerable<T>和ienumerable<of T>有什么区别
- 从SQL数据库中读取RTF到richtextbox,如何不把之前的数据覆盖掉,并追加其后
- 标识属性问题!
- 请教高手,C#基于Remoting的C/S结构程序服务端内存溢出问题
- 请问ASP.NET中画直线的函数是什么?
- C# 读取Excle数据报错,多种解决办法尝试都未能解决,急求帮助
- c#中能不能用公用变量和函数?
- C#可否调用原先的MFC库
- VS下调试运行时正常,直接运行exe文件时会有卡顿
- C#中的DateTimePicker控件不能在Windows98中正常运行
- 如何在RichTextBox中加入超文本链接
应该是
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBa/[email protected]";
"Password=xxx;",
"User ID=xxx;",
"Data Source=xxx;",
"Persist Security Info=True");
this.Text = sCon;
this.listBox1.Items.Clear();
try
{
//用oracle支持连接
System.Data.OracleClient.OracleConnection ocnMain = new System.Data.OracleClient.OracleConnection(sCon);
ocnMain.Open();
//打开Command
System.Data.OracleClient.OracleCommand cmdMain = new System.Data.OracleClient.OracleCommand();
cmdMain.Connection = ocnMain;
cmdMain.CommandText = "SELECT distinct table_name FROM cols";
//
System.Data.OracleClient.OracleDataReader odrMain = cmdMain.ExecuteReader();
while (odrMain.Read())
{
this.listBox1.Items.Add(odrMain.GetString(0));
this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
//关闭连接
ocnMain.Close(); }
catch(System.Exception eException)
{
MessageBox.Show(eException.Message.ToString());
}********************************************************************
*TryMyBestToKnowSomethingAboutEverythingAndEverythingAboutSomething!
********************************************************************
// Change the directory to %WINDIR%
Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");
DirectoryInfo info = new DirectoryInfo(".");
lock(info)
{
Console.WriteLine("Directory Info: "+info.FullName);
}