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...

Thanx Veena,
and secondly, how can I change the path during runtime?

Hi,

Just change the datasource property in ConnString:

With conn
.ConnectionString = "Provider = Microsoft.JET.OLEDB.4.0; data source = \\SharedFolderName\reservation97.mdb; persist security info = false"
.Open
End With

Regards
Veena

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 :)

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

Yeah that's what I was asking. thank you a lot veena, really..

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

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..

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.