473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DNS-less Connections

slc
Help,

I'm trying to make the following asp code work using a DNS-Less
connection on a windows 2000 server running IIS and ODBC 4.0 driver.
The Access database (odbc_exmp.mdb) was made using Access 2002. The
code works if I set up a DNS on the server under the ODBC drivers.
What I'm I doing wrong and what do I change the code to, to make it
work using DNS-Less connection?

Thanks for any help
Kevin.
<% Response.buffer = true %>
<html>
<head>
<title>Testing of odbc_exmp asp</title>
</head>
<body>
<%
'Next 4 lines do not work
Dim rs, dbPath
dbPath = "c:\safety\tr\odbc_exmp.mdb"
Set rs = Server.CreateObject("ADODB.Connection")
rs.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

' The next 3 lines work with DNS set up on the windows 2000
server-IIS-ODBC 4.0 drivers
'Dim rs
'Set rs = Server.CreateObject ("ADODB.Recordset")
'rs.Open "names", "DSN=odbc_exmp",,, &H0200

While Not rs.EOF
'Response.Write "ID : " & rs("id") & "<br>"
Response.Write "First Name : " & rs("first_name") & "<br>"
Response.Write "Last Name : " & rs("last_name") & "<br>"
Response.Write "<br>"
Response.Write "<br>"
rs.MoveNext
Wend

rs.Close
Set rs = Nothing %>
</body>
</html>

Jul 22 '05 #1
4 2247
> Dim rs, dbPath
dbPath = "c:\safety\tr\odbc_exmp.mdb"
Set rs = Server.CreateObject("ADODB.Connection")
You have the variable named RS but have instantiated a Connection object.
Try changing it to an ADODB.Recordset
rs.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
You need some sort of SQL statement of something to let it know what to pull
from the database.

'---------------------------------------Code Sample:
'Create the Connection string
Dim strConnStr, dbPath
dbPath = "c:\safety\tr\odbc_exmp.mdb"
strConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath

'Create the SQL Statement
Dim strSQL
strSQL = "SELECT id, first_name, last_name FROM MyTable

'Open the Recordset
Dim RS
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open strSQL, strConnStr

'Loop through the records
With RS
If Not .EOF Then
Do Until .EOF
Response.Write "ID : " & RS("id").Value & "<br />"
.MoveNext
Loop
End If
End With

'Cleanup
RS.Close
Set RS = Nothing
'-------------------------End Code sample
**- Make sure you change MyTable to the actual table name in your DB
** - On the line 'RS.Open strSQL, strConnStr' you should include the
constants for a Forward Only, Read only recordset (firehose recordset) as
this is the most efficient kind in this type of use

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

<sl*@cfl.rr.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... Help,

I'm trying to make the following asp code work using a DNS-Less
connection on a windows 2000 server running IIS and ODBC 4.0 driver.
The Access database (odbc_exmp.mdb) was made using Access 2002. The
code works if I set up a DNS on the server under the ODBC drivers.
What I'm I doing wrong and what do I change the code to, to make it
work using DNS-Less connection?

Thanks for any help
Kevin.
<% Response.buffer = true %>
<html>
<head>
<title>Testing of odbc_exmp asp</title>
</head>
<body>
<%
'Next 4 lines do not work
Dim rs, dbPath
dbPath = "c:\safety\tr\odbc_exmp.mdb"
Set rs = Server.CreateObject("ADODB.Connection")
rs.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

' The next 3 lines work with DNS set up on the windows 2000
server-IIS-ODBC 4.0 drivers
'Dim rs
'Set rs = Server.CreateObject ("ADODB.Recordset")
'rs.Open "names", "DSN=odbc_exmp",,, &H0200

While Not rs.EOF
'Response.Write "ID : " & rs("id") & "<br>"
Response.Write "First Name : " & rs("first_name") & "<br>"
Response.Write "Last Name : " & rs("last_name") & "<br>"
Response.Write "<br>"
Response.Write "<br>"
rs.MoveNext
Wend

rs.Close
Set rs = Nothing %>
</body>
</html>

Jul 22 '05 #2
sl*@cfl.rr.com wrote:
Help,

I'm trying to make the following asp code work using a DNS-Less
connection on a windows 2000 server running IIS and ODBC 4.0 driver.
The Access database (odbc_exmp.mdb) was made using Access 2002. The
code works if I set up a DNS on the server under the ODBC drivers.
What I'm I doing wrong and what do I change the code to, to make it
work using DNS-Less connection?

Thanks for any help
Kevin.
<% Response.buffer = true %>
<html>
<head>
<title>Testing of odbc_exmp asp</title>
</head>
<body>
<%
'Next 4 lines do not work
What does "doesn't work" mean? Error messages? Incorrect behavior? Please
try to describe your symptoms without using the words "doesn't work", or "no
luck", or some other phrase that assumes your readers are able to read your
mind. :-)
Dim rs, dbPath
dbPath = "c:\safety\tr\odbc_exmp.mdb"
Set rs = Server.CreateObject("ADODB.Connection")
rs.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
"rs" for a connection object??? Do you want it make it impossible for
someone to debug your code?? Join the rest of the world and use "cn" or
"conn" for the name of your connection object variable.
' The next 3 lines work with DNS set up on the windows 2000
server-IIS-ODBC 4.0 drivers
'Dim rs
'Set rs = Server.CreateObject ("ADODB.Recordset")
'rs.Open "names", "DSN=odbc_exmp",,, &H0200


You've just redefined the rs variable. It's now a recordset object. Was that
intentional? Anyways, it's a bad idea to use a connection string in your
recordset's Open statement. You may be disabling connection pooling by doing
so. Always use an explicit connection object.

It's also not a good idea to open your entire names table when your intent
is to display two of the fields in it. Do this instead:

Dim rs, dbPath, cn, sSQL
dbPath = "c:\safety\tr\odbc_exmp.mdb"
sSQL= "Select [id],first_name,last_name From [names]"
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
Set rs = cn.Execute(sSQL,,1)
For a potentially major performance improvement, use a GetRows array:

dim arData
If Not rs.EOF then arData = rs.GetRows
rs.close: set rs=nothing
cn.close: set cn=nothing
if isArray(arData) then
dim i
for i = 0 to ubound(arData,2)
Response.Write "ID : " & arData(0,i) & "<br>"
Response.Write "First Name : " & arData(1,i) & "<br>"
Response.Write "Last Name : " & arData(2,i) & "<br>"
Response.Write "<br>"
Response.Write "<br>"
next
else
response.write "No Records were returned"
end if
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #3
Chris,

Thank You for the sample code.
I fix the line that says strSQL = "SELECT id, first_name, last_name
FROM MyTable
to read
strSQL = "SELECT id, first_name, last_name FROM [MyTable]"
and it works grate.

(Boy, was my code mested up)

Again Thanks for the Help.

Kevin

Jul 22 '05 #4
slc
Bob,

Thanks for the Help, your code works grate.
I will try to do beater need time on describing my symptoms.
Again Thanks for the help and setting me strate.

Kevin

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: GriffithsJ | last post by:
I have a series of websites, let's call them "customer1.mydomain.co.uk" --> "customer200.mydomain.co.uk". Each URL is bound to an individual IP address which can be resolved using nslookup. ...
9
by: Leigh | last post by:
Hi, Is it possible to interface with the DNS Server to create and delete records? I trying to create a utility that will create (A) Host records automatically. Any information, help or examples...
7
by: Roger Bavaud | last post by:
Hello Does anybody know, how I can create new Recorts in a DNS Server from an ASP.Net Application? I will build this on a Web managemant site. Thanks & Best Regards Roger
2
by: David Arden Stevensonn | last post by:
On 'sub1.othercompany.com' there is a simple php file with an include that calls a script on my company's server 'sub2.mycompany.com' The script on my company's server seems to work fine when I...
4
by: MSNews | last post by:
I get the following exception when calling Dns.GetHostName (from C#): An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll Additional information: An...
7
by: kvnsdr | last post by:
I can type an IP address and receive Internet domain name and my workstation name however no other IPs of computers on our internal network will resolve to a thier machine name only to the same IP...
9
by: Michael | last post by:
Hi, I am trying to create a CName record on my DNS server. Seems like it should be easy. I am using WMI. I have created a test asp.net page and put the code in the code behind. The DNS server...
1
by: Screenbert | last post by:
I have a web page that displays and creates DNS entries. It displays DNS entries if they exist for certain IP ranges. (Usually about 20 IP address at a time) If a DNS entry needs to be created then...
0
by: HandleX609 | last post by:
http://i103.photobucket.com/albums/m135/handlex/RandomPhotos/Buttsex_to-Korn.jpg This is the snapshot stating the event for a certain zone. ...
5
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I am trying to get the DNS name of an arbitrary IP address on the network. If I use GetHostEntry as the documentation suggests I only get the name of the machine I am running the code on. All...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.