Link to home
Start Free TrialLog in
Avatar of ibabic
ibabic

asked on

VB application with Access DB on the WWW

How can i do to connect a VB6 Application with an Access Database located in a Web Server? I have the mdb in the server, and i have all the permissions to write, read, etc. i made an ASP application that allows me to do anything on it. it already works.
But things have changed. Now, how can i do to make a remote connection with it from my computer? I want to develope a VB6 application to read and write data on that database. How do i do?
Avatar of harnal
harnal

The easyest way would be to Create an "ActiveX document.exe" in the VB application menu.  

Then add a "Data" control. Set the control's connect property to "Access".

Set the "databaseName" property to the path of your database then set the RecordSource Property to the table or record you want to read/add/edit.

Then you can use it through a browser just like a standalone .EXE.

Best of luck!
I suppose you have two options.

First solution is to communicate from VB app with your existing ASP application via HTTP using Inet control or Winsock Control, or WinInet API etc.

Second option is a right way :) provided by MS. It is RDS - Remote Data Services. It allows you to work with a database located on the web server via HTTP.

For more info take a look at http://www.microsoft.com/data/ado/rds/
Avatar of ibabic

ASKER

I tried rds´s control, but it didn´t work for me.
Try the activex document.exe, it is just as easy to write may be even less work.  It will cut your code time in half.  You can set most of your connection properties at design time.
You can try using oledb conection giving ip address
ASKER CERTIFIED SOLUTION
Avatar of rogerrgr
rogerrgr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibabic

ASKER

Dear rogerrgr:

Can you explain this line of code

Private Sub Command1_Click()
Get_Recordset strConnect := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\ftp\sample\Database\sample.mdb", strSQL := "select * from foo", strURL := "http://myserver

What is the source?
if i connect to my server, where do i introduce the path to the database?
i didn't understand your answer, but i think i'd work. can you help me?

Ivan Babic
ibabic@hotmail.com
The Get_Recordset sub expects a connection string (strConnect), a record retrieving SQL statement (strSQL) and an URL pointing to the web server (strURL), all of which are explained here:

-->strConnect: this string holds the information to get connected (i.e.: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\ftp\sample\Database\sample.mdb").

-->strSQL:  this string holds the information to retrieve a set of records (i.e.: "select * from foo").

-->strURL: this string holds the IP address or server name of the web server, you just have to point to the machine, but do not have to use additional folder information (i.e.: use http://www.myserver.com, not http://www.myserver.com/folder/databases/...)

You should note that the connection string contains a "Provider" parameter to tell ADO which data provider to use for the connection and a "Data Source" parameter to point to the databases's physical location (hard disk path, not virtual folder) in the server.

Hope this helps...
Avatar of ibabic

ASKER

and what is this?

DataSource=d:\ftp\sample\Database\sample.mdb"

is a local database or what?

It is the hard disk's path to the database in the server machine.  This UNC address is used in the server to open the MS Access file.

You just have to ask the web server's administrator the path to the file, for example:  if the web server has a big hard disk called "D", and all MS Access databases are stored in a "databases" folder and you want to work with a database called "sample.mdb", you have to change that line to point to it as in DataSource=d:\databases\sample.mdb, it has nothing to do with your client machine.

On the other hand, it is possible to change this parameter to DSN=MyDSN and use an standard DSN connection to the database, but the DSN must be configured in the web server.

Finally, I recall that you first used an ASP web page to work with the database, maybe you can post the code section where the connection to the database is made.
Avatar of ibabic

ASKER

and when i try to access the database trough the RDS, the machine connects automatically to the web server and retrieves the data?
Not exactly.  When you try to access data through RDS, you instantiate an object in the web server (a datafactory object in our case) and get a reference to it.  In other words, the server impersonates the client, gets a connection, gathers data and sends a recordset to you, but the client is completely isolated from all that management.
Avatar of ibabic

ASKER

I solved my problem last week with an ASP that retrieves data from a request made with an INet Control from Visual Basic 6 and writes in the response the result of the action, so i can capture the result from vb6.
I tried with the RDS, but i wasn't successful.
What is the advantage of using the RDS?
Is it faster? is it easier? or what?
RDS gives you access to recordset objects which can be manipulated in many ways (i.e. using them for filtering, sorting, making batch operations) in the client, without any further trips to the server.  The previous advantages make them faster for some user services and I guess it is easier to work with them instead of parsing strings, but it all depends on one's preferences and how fancy your program needs to be.
Avatar of ibabic

ASKER

I'm giving you the points Rogerrgr.
Please send me your email just in case i have some doubts in the future.
Ivan Babic
ibabic@hotmail.com
Thank you...
Róger Guillén
roger@cesand.co.cr
Avatar of ibabic

ASKER

Roger
De donde eres?
Costa Rica