problem with path in connecting to an access database

Yeung

Member
Joined
Jun 15, 2007
Messages
22
Programming Experience
Beginner
Hi,

I've just started learning database programming with ado.net and i was successful in creating an application that will display a data on a grid. But i am opening my application on diff. computers one at my home and at school.

I was wondering however on how can i make my application to look for the access database in the same folder as my application. because i do not want to change the path from the windows generated code everytime i will open my application on different computers.

also how can i connect to a database using codes and how to bind them to textboxes,comboboxes etc. and add, update ,edit, delete them from within that code.

Thanks!
 
put ur access database in your /bin folder

Define a module in ur project and code ur connection string in the project as

VB.NET:
Public Const dataSource As String = "YourDataBaseName.mdb"
Public strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & dataSource &";User Id=Admin; Password=;"

and use this strConn in all ur adapters
 
Last edited:
Back
Top