如何把绝对路径(d:\\)改成虚拟路径
==============================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class Default2 : System.Web.UI.Page
{
private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Test.mdb ";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
OleDbConnection Conn = new OleDbConnection(AcessConectionStr);
Conn.Open();
string name = this.TextBox1.Text;
string pwd = this.TextBox2.Text;
string strSQL = "INSERT INTO login(userName,pwdInput) values( ' " + name + " ', ' " + pwd + " ') ";
OleDbCommand AcessCommand = new OleDbCommand(strSQL, Conn);
AcessCommand.ExecuteNonQuery();
Conn.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
------解决方案--------------------Sever.path(....);
------解决方案--------------------Page.Server.MapPath( "~ ");
------解决方案--------------------另:需要把你的MDB文件放到你的WEB项目下
------解决方案--------------------.Server.MapPath( "~ ");
------解决方案--------------------Page.Server.MapPath( "~ ");