-
Open Database from Command line
Dear ladies and gentlemen,
I have a vb6.0 application. The back end is 2 access 97 database one on the
network the other on the local drive.
For local drive:
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB atabase Password") = "password"
.Open "c:\Directory\ localDatabase.mdb"
End With
For network :
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB atabase Password") = "password"
.Open App.Path & "\NetworkDatabas.mdb"
End With
I would like to locate the local database programmatically without using
.Open "c:\Directory\Databaselocal.mdb"
I try to use the command line but I can not applied to my code. For Example,
If I have a shortcut and my target is:
S:Networkapplication c:\localDatabase.mdb
And when we create the shortcut we can use any local drive C or D. also how
can I write this code in my VB application and the ADO.
Any Ideas will be appreciated. If you have the code will be great help.
Thank a lot in advance.
John
-
Re: Open Database from Command line
"John" <misbn@yahoo.com> wrote:
>
>Dear ladies and gentlemen,
>
>I have a vb6.0 application. The back end is 2 access 97 database one on
the
>network the other on the local drive.
>
>
>For local drive:
>Dim cn As ADODB.Connection
> Set cn = New ADODB.Connection
> With cn
> .Provider = "Microsoft.Jet.OLEDB.4.0"
> .Properties("Jet OLEDB atabase Password") = "password"
> .Open "c:\Directory\ localDatabase.mdb"
> End With
>
>
>For network :
>Set cn = New ADODB.Connection
>With cn
> .Provider = "Microsoft.Jet.OLEDB.4.0"
> .Properties("Jet OLEDB atabase Password") = "password"
> .Open App.Path & "\NetworkDatabas.mdb"
>End With
>
>I would like to locate the local database programmatically without using
>
>
> .Open "c:\Directory\Databaselocal.mdb"
>
>I try to use the command line but I can not applied to my code. For Example,
>
>If I have a shortcut and my target is:
>
>S:Networkapplication c:\localDatabase.mdb
>
>And when we create the shortcut we can use any local drive C or D. also
how
>can I write this code in my VB application and the ADO.
>
>Any Ideas will be appreciated. If you have the code will be great help.
>
>
>Thank a lot in advance.
>
>John
>
>
John,
You have to write code to get and do something with the argument passed in
to your app on the command line. Use the Command function. For example:
Dim sDatabaseFileName as string
Dim oConneciton as ADODB.Connection
sDatabaseFileName = Command()
set oConnection = New ADODB.Connection
oConneciton.Open sDatabaseFileName
-
Re: Open Database from Command line
Hi Adam
This code is in my command line (Shortcut).
C:\Project.exe "DBPath=C:\DirectoryName\DatabaseName.mdb"
The following is my VB code but it did not work.
dim sDBPath as string
dim cn as adodb.connection
sDBPath= Right(Command,(len(Command)-instr(Command,"=")))
set cn =new adodb.connection
cn.password ="password"
cn.open sDBPath
Also I tried your code not working ether. Is my command line (shortcut) code
is right? I am sorry but this the first time I am using this way.
Any Idea thanks.
John
"Adam" <adam.strakna@prometric.com> wrote:
>
>"John" <misbn@yahoo.com> wrote:
>>
>>Dear ladies and gentlemen,
>>
>>I have a vb6.0 application. The back end is 2 access 97 database one on
>the
>>network the other on the local drive.
>>
>>
>>For local drive:
>>Dim cn As ADODB.Connection
>> Set cn = New ADODB.Connection
>> With cn
>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>> .Properties("Jet OLEDB atabase Password") = "password"
>> .Open "c:\Directory\ localDatabase.mdb"
>> End With
>>
>>
>>For network :
>>Set cn = New ADODB.Connection
>>With cn
>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>> .Properties("Jet OLEDB atabase Password") = "password"
>> .Open App.Path & "\NetworkDatabas.mdb"
>>End With
>>
>>I would like to locate the local database programmatically without using
>>
>>
>> .Open "c:\Directory\Databaselocal.mdb"
>>
>>I try to use the command line but I can not applied to my code. For Example,
>>
>>If I have a shortcut and my target is:
>>
>>S:Networkapplication c:\localDatabase.mdb
>>
>>And when we create the shortcut we can use any local drive C or D. also
>how
>>can I write this code in my VB application and the ADO.
>>
>>Any Ideas will be appreciated. If you have the code will be great help.
>>
>>
>>Thank a lot in advance.
>>
>>John
>>
>>
>John,
>
>You have to write code to get and do something with the argument passed
in
>to your app on the command line. Use the Command function. For example:
>
>
> Dim sDatabaseFileName as string
> Dim oConneciton as ADODB.Connection
>
> sDatabaseFileName = Command()
> set oConnection = New ADODB.Connection
> oConneciton.Open sDatabaseFileName
>
>
>
>
-
Re: Open Database from Command line
"John" <misbn@yahoo.com> wrote:
>
>Hi Adam
>
>This code is in my command line (Shortcut).
>
>C:\Project.exe "DBPath=C:\DirectoryName\DatabaseName.mdb"
>
>The following is my VB code but it did not work.
>
>dim sDBPath as string
>dim cn as adodb.connection
>
>sDBPath= Right(Command,(len(Command)-instr(Command,"=")))
>set cn =new adodb.connection
>cn.password ="password"
>cn.open sDBPath
>
>Also I tried your code not working ether. Is my command line (shortcut)
code
>is right? I am sorry but this the first time I am using this way.
>
>Any Idea thanks.
>
>John
>
>"Adam" <adam.strakna@prometric.com> wrote:
>>
>>"John" <misbn@yahoo.com> wrote:
>>>
>>>Dear ladies and gentlemen,
>>>
>>>I have a vb6.0 application. The back end is 2 access 97 database one on
>>the
>>>network the other on the local drive.
>>>
>>>
>>>For local drive:
>>>Dim cn As ADODB.Connection
>>> Set cn = New ADODB.Connection
>>> With cn
>>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>>> .Properties("Jet OLEDB atabase Password") = "password"
>>> .Open "c:\Directory\ localDatabase.mdb"
>>> End With
>>>
>>>
>>>For network :
>>>Set cn = New ADODB.Connection
>>>With cn
>>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>>> .Properties("Jet OLEDB atabase Password") = "password"
>>> .Open App.Path & "\NetworkDatabas.mdb"
>>>End With
>>>
>>>I would like to locate the local database programmatically without using
>>>
>>>
>>> .Open "c:\Directory\Databaselocal.mdb"
>>>
>>>I try to use the command line but I can not applied to my code. For Example,
>>>
>>>If I have a shortcut and my target is:
>>>
>>>S:Networkapplication c:\localDatabase.mdb
>>>
>>>And when we create the shortcut we can use any local drive C or D. also
>>how
>>>can I write this code in my VB application and the ADO.
>>>
>>>Any Ideas will be appreciated. If you have the code will be great help.
>>>
>>>
>>>Thank a lot in advance.
>>>
>>>John
>>>
>>>
>>John,
>>
>>You have to write code to get and do something with the argument passed
>in
>>to your app on the command line. Use the Command function. For example:
>>
>>
>> Dim sDatabaseFileName as string
>> Dim oConneciton as ADODB.Connection
>>
>> sDatabaseFileName = Command()
>> set oConnection = New ADODB.Connection
>> oConneciton.Open sDatabaseFileName
>>
>>
>>
>>
>
John,
I think the quotation marks are causing your problem. You do not need them
and if you use them your code has to compensate for it. Also, you do not
need the 'DBPath=' in your command line - just the path to the .mdb file
is fine.
FYI...
You can test your command line in the development environment by specifying
a command line in the 'command line arguments' on the 'make' tab of the project
properties. This way you can walk through the code and see exactly what
is happening.
Adam
-
Re: Open Database from Command line
Thanks a lot Adam for your help it did work.
John
"Adam" <adam.strakna@prometric.com> wrote:
>
>"John" <misbn@yahoo.com> wrote:
>>
>>Hi Adam
>>
>>This code is in my command line (Shortcut).
>>
>>C:\Project.exe "DBPath=C:\DirectoryName\DatabaseName.mdb"
>>
>>The following is my VB code but it did not work.
>>
>>dim sDBPath as string
>>dim cn as adodb.connection
>>
>>sDBPath= Right(Command,(len(Command)-instr(Command,"=")))
>>set cn =new adodb.connection
>>cn.password ="password"
>>cn.open sDBPath
>>
>>Also I tried your code not working ether. Is my command line (shortcut)
>code
>>is right? I am sorry but this the first time I am using this way.
>>
>>Any Idea thanks.
>>
>>John
>>
>>"Adam" <adam.strakna@prometric.com> wrote:
>>>
>>>"John" <misbn@yahoo.com> wrote:
>>>>
>>>>Dear ladies and gentlemen,
>>>>
>>>>I have a vb6.0 application. The back end is 2 access 97 database one
on
>>>the
>>>>network the other on the local drive.
>>>>
>>>>
>>>>For local drive:
>>>>Dim cn As ADODB.Connection
>>>> Set cn = New ADODB.Connection
>>>> With cn
>>>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>>>> .Properties("Jet OLEDB atabase Password") = "password"
>>>> .Open "c:\Directory\ localDatabase.mdb"
>>>> End With
>>>>
>>>>
>>>>For network :
>>>>Set cn = New ADODB.Connection
>>>>With cn
>>>> .Provider = "Microsoft.Jet.OLEDB.4.0"
>>>> .Properties("Jet OLEDB atabase Password") = "password"
>>>> .Open App.Path & "\NetworkDatabas.mdb"
>>>>End With
>>>>
>>>>I would like to locate the local database programmatically without using
>>>>
>>>>
>>>> .Open "c:\Directory\Databaselocal.mdb"
>>>>
>>>>I try to use the command line but I can not applied to my code. For Example,
>>>>
>>>>If I have a shortcut and my target is:
>>>>
>>>>S:Networkapplication c:\localDatabase.mdb
>>>>
>>>>And when we create the shortcut we can use any local drive C or D. also
>>>how
>>>>can I write this code in my VB application and the ADO.
>>>>
>>>>Any Ideas will be appreciated. If you have the code will be great help.
>>>>
>>>>
>>>>Thank a lot in advance.
>>>>
>>>>John
>>>>
>>>>
>>>John,
>>>
>>>You have to write code to get and do something with the argument passed
>>in
>>>to your app on the command line. Use the Command function. For example:
>>>
>>>
>>> Dim sDatabaseFileName as string
>>> Dim oConneciton as ADODB.Connection
>>>
>>> sDatabaseFileName = Command()
>>> set oConnection = New ADODB.Connection
>>> oConneciton.Open sDatabaseFileName
>>>
>>>
>>>
>>>
>>
>John,
>
>I think the quotation marks are causing your problem. You do not need them
>and if you use them your code has to compensate for it. Also, you do not
>need the 'DBPath=' in your command line - just the path to the .mdb file
>is fine.
>
>FYI...
>
>You can test your command line in the development environment by specifying
>a command line in the 'command line arguments' on the 'make' tab of the
project
>properties. This way you can walk through the code and see exactly what
>is happening.
>
>Adam
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks