Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Developers!!!!

I want to build a ASP.NET website by using a MS ACCESS database and C# Language.I have searched a lot but i can't find write answer.
Whenever i try to find connectivity solution, The code that i found on Google search is Like
<pre>
using System.Data.Oledb;


__________________________________
namespace consample
{
pubic class OledbConnection
{
public void Perform()
{
OledbConnection con= new OledbCOnnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb")//Data provider for MS ACCESS
con.Open();
OLEDBCommand cmd=new OLEDBCOmman();
cmd.Connection=con;
cmd.CommandType=CommandType.Text;
cmd.CommandText="Select * from emp";
OledbDataReader dr= new OledbDataReader();
dr=cmd.Executereader();
while (dr.Read()==true)
{
/// Do some coding here
}
}
}
}

__________________________________________


I am totally confused that why they only give local host or C:\ path if we want to upload our site on Internet server.
Please help me out to sort this Problem. I will be very thankful to You.
Posted
Updated 6-Jun-10 21:15pm
v2

1 solution

You can use Server.MapPath() to locate the access file in connectionString so that it searches in deployed location where application resides. Here main purpose is at runtime application should be able to locate the access data file.
code snnipet:
OledbConnection con= new OledbCOnnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("mydatabase.mdb")+";";


Please let us know whethe it helps you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900