943,965 Members | Top Members by Rank

Ad:
Aug 20th, 2007
0

changing ms access database path during runtime

Expand Post »
hi everybody,

my connection code is like this:

Set conn = New ADODB.Connection

With conn
.ConnectionString = "Provider = Microsoft.JET.OLEDB.4.0; data source = C:\Documents and Settings\kullaniciadi\Desktop\reservation97.mdb; persist security info = false"
.Open
End With


This database (reservation97.mdb) is going to be moved to a server.. How is going to be the path string then? (e.i. \\server\foldername...) ??

And to change the path by an admin when program starts, what should I add to source code? thanx...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t_yalthis is offline Offline
22 posts
since Jul 2007
Aug 20th, 2007
0

Re: changing ms access database path during runtime

Hi,

Yes it should be "\\ServerSharedFolderName\reservation97.mdb"

Note here, the Sahred Folder in Server Name Should Have Complete Read/Write Access..

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 20th, 2007
0

Re: changing ms access database path during runtime

Thanx Veena,
and secondly, how can I change the path during runtime?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t_yalthis is offline Offline
22 posts
since Jul 2007
Aug 20th, 2007
0

Re: changing ms access database path during runtime

Hi,

Just change the datasource property in ConnString:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. With conn
  2. .ConnectionString = "Provider = Microsoft.JET.OLEDB.4.0; data source = <a rel="nofollow" href="file://\\SharedFolderName\reservation97.mdb" target="_blank">\\SharedFolderName\reservation97.mdb</a>; persist security info = false"
  3. .Open
  4. End With

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 20th, 2007
0

Re: changing ms access database path during runtime

yeah I now how to change it; but I think I couldn't explain very well..
admin is going to install the program, and he will want to change the path of the database. is there anyway to change it without writing the code as you explained above, compile it, create the .exe and setup file again?

otherwise it is simple to change it while coding..

thanx for the patiance btw
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t_yalthis is offline Offline
22 posts
since Jul 2007
Aug 20th, 2007
0

Re: changing ms access database path during runtime

Hi,

Always, in RealTime Projects what we do is Save the Databasepath in an Initialization Text File or another Password protected Database mdb file. So, Open the Textfile, Read the Path and close it, not open the Database with the new path. Disadvantage of this TextFile is, anybody can browse and find the Path, and they may tamper its text data. Always, its a Good Option to Query from a Small Another mdb file and always save it in Current Folder Location. Even if somebody tries to open it, it is Password protected, and cannot Tamper with its Data..
I Hope I'am clear.

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 20th, 2007
0

Re: changing ms access database path during runtime

Yeah that's what I was asking. thank you a lot veena, really..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t_yalthis is offline Offline
22 posts
since Jul 2007
Mar 7th, 2008
0

Re: changing ms access database path during runtime

i had done a project in vb using Msacess , i want to display the tables name in my form , pls help me for to complete my project
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinothmanimaran is offline Offline
2 posts
since Mar 2008
Jan 13th, 2009
0

Re: changing ms access database path during runtime

HI THERE, i wana connect msaccess database to vb6, so that i can be able to view the data in the tables in the database in the listbox, so far this the code i used to connect but get this error "The connection cannot be used to perfom this operation. its either closed or ivalid in this context." my database name is"Storenw", and the table i want to access is "sales". can any one help or tell me wher i went wrong..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Option Explicit
  3. Private Sub cmdbuynow_Click()
  4. Dim cn As New ADODB.Connection
  5. Dim strCNString As String
  6. Dim rs As New ADODB.Recordset
  7. Dim Txt As String
  8. On Error GoTo ErrHandler
  9. 'Connect to database
  10. strCNString = "Data Source=" & App.Path & "\Storenw.mdb" cn.Provider = "Microsoft Jet 4.0 OLE DB Provider" cn.ConnectionString = strCNString cn.Properties("Jet OLEDB:Database Password") = ""
  11. cn.Open
  12. 'Open recordsource
  13. With rs
  14. .Open "Select * from sales , cn, adOpenDynamic, adLockOptimistic"
  15. cn.Close
  16. Unload Me
  17. frmSales.Show
  18. End With
  19. ExitHere:
  20. Exit Sub
  21. ErrHandler:
  22. MsgBox Err.Number & " " & Err.Description, vbCritical, "Error!!!" cn.Close
  23. End Sub
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:54 am. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jan 13th, 2009
0

Re: changing ms access database path during runtime

Quote ...
can any one help or tell me wher i went wrong..
1) You didn't start your own thread.
2) You didn't use code tags.
3) You didn't post which line is highlighted when it goes into debug
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: i need a random generator
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Help! Print the Text in a Textbox and / or Label to Printer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC