Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2005, 08:44 AM
Authorized User
 
Join Date: Mar 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default SERVER_CONNECT

 How can connect to an SERVER IIS from Visual Basic, where is my MS Access DataBase?

                                 Thanks for you repley!


 
Old March 27th, 2005, 11:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Ioan,

If you are trying to display data from an Access db in a web page hosted on IIS using VB, here's the bare bones of creating a virtual directory, an ASP page and an ADO connection using VB script.

1. Your IIS default web site is typically C:\Inetpub\wwwroot. Create a new virtual directory in your IIS root directory, like C:\Inetpub\wwwroot\AccessVB.

2. Use notepad to create a simple ASP page called CustomerNames.asp in the AccessVB directory:

Code:
<HTML>
<HEAD>
<TITLE>Connecting to An Access Db</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>
Using ADO in a Visual Basic Script Web Page
</H1>
<H2>Connecting to an Access Db on your local computer</H2>


<! server side script >

<%

dim cnn
dim rstCompanyName

set cnn = Server.CreateObject("ADODB.Connection")

cnn.open "Provider=Microsoft.Jet.OLEDB.4.0;" _
                 & "Data Source=C:\Northwind.mdb"

strSQL = "SELECT CompanyName FROM Customers"

set rstCompanyName =  cnn.Execute(strSQL)

do until rstCompanyName.eof
  Response.Write rstCompanyName("CompanyName")  %>
  <BR>
  <%
  rstCompanyName.movenext
loop

rstCompanyName.close
set rstCompanyName = nothing
%>
<! end server side script>


</CENTER>
</BODY>
</HTML>
This page uses an ADO connection to connect to a database stored on your C: drive (C:\Northwind.mdb).

3. With the virtual directory created, the ASP page stored in the virtual directory, and a copy of the Northwind db placed on your C: drive, type the following into your browser:

http://localhost/AccessVB/CustomerNames.asp

You should see a web page that lists the names of all the customers stored in the Northwind db.

HTH,

Bob










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.