Solved

VB application with Access DB on the WWW

Posted on 2000-03-16
18
164 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:ibabic
  • 7
  • 7
  • 2
  • +2
18 Comments
 
LVL 2

Expert Comment

by:harnal
Comment Utility
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!
0
 
LVL 2

Expert Comment

by:gelog
Comment Utility
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/
0
 

Author Comment

by:ibabic
Comment Utility
I tried rds´s control, but it didn´t work for me.
0
 
LVL 2

Expert Comment

by:harnal
Comment Utility
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.
0
 

Expert Comment

by:xolotl
Comment Utility
You can try using oledb conection giving ip address
0
 
LVL 1

Accepted Solution

by:
rogerrgr earned 500 total points
Comment Utility
You may use Microsoft's Remote Data Services (ADO RDS) to connect to a database on a web server.  First, you should add references in your project to Microsot ActiveX Data Objects 2.0 Library and Microsoft Remote Data Services 2.1 Library.  Then try the following code to retrieve a recordset:

dim rs as ADODB.Recordset
dim ds as RDS.DataSpace
dim df as Object

Private Sub Get_Recordset(strConnect as string, strSQL as string, strURL as string)
set ds = new RDS.Dataspace
set df = ds.CreateObject("RDSServer.DataFactory", strURL)
set rs = df.Query(strConnect, strSQL)
End Sub

'Let's asume you want to call the Get_Recorset Sub in a command click event

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"
With rs
Do until .EOF
Debug.print .fields(0).value
..MoveNext
Loop
end with
End Sub

Please note that you must provide a set of arguments that matches your current scenario when calling the Get_Recordset sub:  you must know the physycal path (in the server) to the database, the http address and a valid recordset retrieving SQL statement.  The web server must be able to run Remote Data Services (installed with ADO) too.

The Query method may also be used to perform action queries that retrieve no records, so just call it without assigning the result to a recordset object.

Hope the above helps...
0
 

Author Comment

by:ibabic
Comment Utility
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
0
 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
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...
0
 

Author Comment

by:ibabic
Comment Utility
and what is this?

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

is a local database or what?

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
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.
0
 

Author Comment

by:ibabic
Comment Utility
and when i try to access the database trough the RDS, the machine connects automatically to the web server and retrieves the data?
0
 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
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.
0
 

Author Comment

by:ibabic
Comment Utility
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?
0
 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
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.
0
 

Author Comment

by:ibabic
Comment Utility
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
0
 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
Thank you...
Róger Guillén
roger@cesand.co.cr
0
 

Author Comment

by:ibabic
Comment Utility
Roger
De donde eres?
0
 
LVL 1

Expert Comment

by:rogerrgr
Comment Utility
Costa Rica
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now