Database Connection problem
Hi,
I am having a connection problem to my database only when i upload the files to my web server. My database lives in a folder called private. I don't know how to point to this database. The database works fine on my local machine just not on my web server.
my code:
Code:
private void Page_Load(object sender, System.EventArgs e)
{
// Connect to the database
OleDbConnection myConn;
OleDbCommand myCmd;
OleDbDataReader myReader;
myConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=//..//..//..//..//private//mydatabase");
String SQL = "SELECT url FROM links";
myCmd = new OleDbCommand(SQL, myConn);
myConn.Open();
myReader = myCmd.ExecuteReader();
displayLinks.DataSource = myReader;
displayLinks.DataBind();
myConn.Close();
}
Problem is with the Data Source, how do i point it to my database, my hosting guys are useless and will not help me!
Any advice or pointers greatly appreciated.
Re: Database Connection problem
modernthinker
This should work (after you make some syntax changes....it's in vb.net)
VB Code:
Dim strOle As String = "private/mydatabase.mdb"
Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath(strOle))
Dawg