如何把绝对路径(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= " + System.We
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);
}
}
}
------解决方案--------------------private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+ Server.MapPath( "../Test.mdb "); "../Test.mdb "为相对路径
------解决方案--------------------Server.MapPath 注意大小写
------解决方案--------------------using System.Web