Results 1 to 2 of 2

Thread: Database Connection problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    The Twilight Zone
    Posts
    295

    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.

  2. #2
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Re: Database Connection problem

    modernthinker

    This should work (after you make some syntax changes....it's in vb.net)

    VB Code:
    1. Dim strOle As String = "private/mydatabase.mdb"
    2. Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath(strOle))

    Dawg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width