Solved

VB application with Access DB on the WWW

Posted on 2000-03-16
18
167 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
ID: 2629112
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
ID: 2644599
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
ID: 2905051
I tried rds´s control, but it didn´t work for me.
0
 
LVL 2

Expert Comment

by:harnal
ID: 2905343
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
ID: 3465714
You can try using oledb conection giving ip address
0
 
LVL 1

Accepted Solution

by:
rogerrgr earned 500 total points
ID: 3737273
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
ID: 3749532
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
ID: 3752979
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
ID: 3773833
and what is this?

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

is a local database or what?

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:rogerrgr
ID: 3776338
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
ID: 3812618
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
ID: 3814314
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
ID: 3819737
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
ID: 3858072
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
ID: 3874592
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
ID: 3875417
Thank you...
Róger Guillén
roger@cesand.co.cr
0
 

Author Comment

by:ibabic
ID: 3880775
Roger
De donde eres?
0
 
LVL 1

Expert Comment

by:rogerrgr
ID: 3885372
Costa Rica
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

930 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

9 Experts available now in Live!

Get 1:1 Help Now