Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting to an access databse on a server

Status
Not open for further replies.

knaya

MIS
Dec 4, 2003
51
US
this sound so simple but its driving me crazy.. i'm trying to connect to an access database on a server using oleDB connection but its not working.. it either says it cant connect to the server or the database is already open by someone else etc.. i'll appreciate any help, i've already spent hours searching google but nothing is working.. Thanks ... i read somehwere you can only connect to an access databse if its located on the c drive.. that cant be true, can it?
 
Here's a simple example on how to connect to an Access database:
Code:
dim oCon as OleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("yourDB.mdb"))
From my experience, any operation that you do on your database shold be placed inside a try ... catch ... end try statement like this:
Code:
Din Err As String
Try
 oCon.Open()
 .... 'your code
Catch ex As Exception
 Err = ex.Message()
Finally
 oCon.Close() 'even if you're having an error, your 
End Try       'connection gets closed

[morning]
 
And it's not true ... your .mdb file can be anywhere! Just make sure that your using Server.MapPath correctly.

[morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top