Code works, but don't know where to place .mdb file !

My code works, but don't know where to place .mdb file !

Page 1 of 1

4 Replies - 2199 Views - Last Post: 20 May 2012 - 02:42 PM Rate Topic: -----

#1 kprawin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-January 10

Code works, but don't know where to place .mdb file !

Posted 16 December 2010 - 11:19 AM

Hi sir,
Im new to Visual Basic, and I tried a simple application using VB2008 and MS-Access. It is a simple application to store Employee ID, Employee Name and Employee Photo.
Both Employee ID and Name are of String type and Photo of OLE type in MS-Access database. I created the file employee.mdb and placed the file in MyProjects folder where my VB application is present.

My Code Works, only if the .mdb file is located in the same location where I choose my photo.
i.e., if I choose my employee photo in 'My Pictures' folder, then the code works only if employee.mdb is present in 'My Pictures' folder. Else it shows an error that it couldn't find employee.mdb
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=employee.mdb" 


Even if I include the full path in the string, it shows the same error.

Please help me in solving the issue. . Thank u in advance. . I have attached the project code hereunder.

Regards,
K.Prawin
(P.S: I know it is a small issue. Im completely new to VB and so I couldn't get the solution. Kindly pardon me for stealing your valuable time.)

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Code works, but don't know where to place .mdb file !

#2 Shadar  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

Re: Code works, but don't know where to place .mdb file !

Posted 16 December 2010 - 01:19 PM

One way to do it is to add it as a resource file. It will automatically add it to the "Resources" folder. Then you can get the app path, and add "\resources\myDatabase.mdb" to it.
Was This Post Helpful? 0
  • +
  • -

#3 sharpy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 394
  • Joined: 02-June 07

Re: Code works, but don't know where to place .mdb file !

Posted 17 December 2010 - 12:09 PM

Hi

I wrote this tut a while back now .




http://www.dreaminco...imple-database/


Doing it this way the connection strings are taken care for you

hope its what you are looking for

regards

Sharpy
Was This Post Helpful? 1
  • +
  • -

#4 digitaldevelopment  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 168
  • Joined: 30-April 12

Re: Code works, but don't know where to place .mdb file !

Posted 19 May 2012 - 01:42 AM

well the thing I am using now is this;
place the database in your resources and refer to it as my.resources.resourceName.databaseName.mdb
Was This Post Helpful? 0
  • +
  • -

#5 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Re: Code works, but don't know where to place .mdb file !

Posted 20 May 2012 - 02:42 PM

Place the MDB file in the Bin\Debug Folder of your application and the connection string line would be :
("Provider = Microsoft.Jet.OleDB.4.0 ; Data Source = " & application.startuppath & "\File.MDB")

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1