changing ms access database path during runtime

Thread Solved

Join Date: Jul 2007
Posts: 22
Reputation: t_yalthis is an unknown quantity at this point 
Solved Threads: 0
t_yalthis t_yalthis is offline Offline
Newbie Poster

changing ms access database path during runtime

 
0
  #1
Aug 20th, 2007
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...
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: changing ms access database path during runtime

 
0
  #2
Aug 20th, 2007
Hi,

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

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

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 22
Reputation: t_yalthis is an unknown quantity at this point 
Solved Threads: 0
t_yalthis t_yalthis is offline Offline
Newbie Poster

Re: changing ms access database path during runtime

 
0
  #3
Aug 20th, 2007
Thanx Veena,
and secondly, how can I change the path during runtime?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: changing ms access database path during runtime

 
0
  #4
Aug 20th, 2007
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" class="t" href="file://\\SharedFolderName\reservation97.mdb" target="_blank">\\SharedFolderName\reservation97.mdb</a>; persist security info = false"
  3. .Open
  4. End With

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 22
Reputation: t_yalthis is an unknown quantity at this point 
Solved Threads: 0
t_yalthis t_yalthis is offline Offline
Newbie Poster

Re: changing ms access database path during runtime

 
0
  #5
Aug 20th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: changing ms access database path during runtime

 
0
  #6
Aug 20th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 22
Reputation: t_yalthis is an unknown quantity at this point 
Solved Threads: 0
t_yalthis t_yalthis is offline Offline
Newbie Poster

Re: changing ms access database path during runtime

 
0
  #7
Aug 20th, 2007
Yeah that's what I was asking. thank you a lot veena, really..
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 2
Reputation: vinothmanimaran is an unknown quantity at this point 
Solved Threads: 0
vinothmanimaran vinothmanimaran is offline Offline
Newbie Poster

Re: changing ms access database path during runtime

 
0
  #8
Mar 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: changing ms access database path during runtime

 
0
  #9
Jan 13th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: changing ms access database path during runtime

 
0
  #10
Jan 13th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC