| | |
changing ms access database path during runtime
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 22
Reputation:
Solved Threads: 0
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...
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...
Hi,
Yes it should be "\\ServerSharedFolderName\reservation97.mdb"
Note here, the Sahred Folder in Server Name Should Have Complete Read/Write Access..
Regards
Veena
Yes it should be "\\ServerSharedFolderName\reservation97.mdb"
Note here, the Sahred Folder in Server Name Should Have Complete Read/Write Access..
Regards
Veena
Hi,
Just change the datasource property in ConnString:
Regards
Veena
Just change the datasource property in ConnString:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With conn .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" .Open End With
Regards
Veena
•
•
Join Date: Jul 2007
Posts: 22
Reputation:
Solved Threads: 0
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
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
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
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
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
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)
Option Explicit Private Sub cmdbuynow_Click() Dim cn As New ADODB.Connection Dim strCNString As String Dim rs As New ADODB.Recordset Dim Txt As String On Error GoTo ErrHandler 'Connect to database 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") = "" cn.Open 'Open recordsource With rs .Open "Select * from sales , cn, adOpenDynamic, adLockOptimistic" cn.Close Unload Me frmSales.Show End With ExitHere: Exit Sub ErrHandler: MsgBox Err.Number & " " & Err.Description, vbCritical, "Error!!!" cn.Close End Sub
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:54 am. Reason: add code tags
![]() |
Similar Threads
- VB: Connect to Access database via ODBC datasource name (Visual Basic 4 / 5 / 6)
- Set runtime connection to the Access database for Crystal report (VB.NET)
- I need help for connecting to Ms access database (VB.NET)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- Updating an Access database with a secondary form (VB.NET)
- Create an Access Database using Java (Java)
- Writing to an Access Database using Java... (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: i need a random generator
- Next Thread: Help! Print the Text in a Textbox and / or Label to Printer
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






