Useful Links
You will need to login before you can post. Please enter the following details:
User Name:    Password: 
Looking for something?
Want to be more precise?
Advanced Search
 

Go Back  NetBusinessTalk.com > Developing an Internet Business > Website Coding & Technology > ASP PART 1


Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-06, 01:06 AM   #1
Active Member
 
Join Date: Sep 2006
Posts: 30
Thumbs up ASP PART 1


ere, you point out how DSN-less connections are faster than System DSN connections because DSN-less avoids doing a registry lookup. This is true; furthremore you can receive additional performance benefits by directly using the OLEDB layer
Here is an example:

Dim Conn, dbPath
dbPath = "d:\myaccessfile.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

I have noticed rather large performance gains, both in server resources and browsing speed on the client with just this change in the code.


Create DSN-Less Connection and use MapPath Method

<%
Option Explicit
' Dimension Local variables
Dim objConn ' Connection Name
Dim strConn ' Connection String
Dim objRS ' Recordset Variable
Dim strSQL ' variable for SQL statement
Dim intTotalColumns
Dim intCounter

Const adOpenStatic = 3
Const adLockReadOnly = 1

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

strConn = "DBQ=" & Server.MapPath("MyDatabase.mdb")
strConn = "DRIVER={Microsoft Access Driver(*.mdb)};" & strConn
objConn.Open strConn

strSQL = "SELECT * FROM Links"
objRS.open strSql, objConn, adOpenStatic, adLockReadOnly

' get the total number of columns
intTotalColumns = objRS.Fields.Count - 1
%>
<TABLE BORDER="1" WIDTH="500">
<tr>
<%
' first display the column names
For intCounter = 0 To intTotalColumns
%>
<TD>
<B>
%=objRS(intCounter).Name%></B>
</TD>
<%
Next

Response.write "</TR>"

' now loop through the recordset and display the data
Do Until objRS.EOF = True
Response.Write "<TR>"
For intCounter = 0 To intTotalColumns
Response.Write "<td width=100 align=center>"
Response.write objRS(intCounter).value
Response.Write "</TD>"
Next
Response.Write "</TR>"

objRS.Movenext
Loop
%>
</TABLE>
<%
' Close Recordset
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>


Want more of ASP OR ASP.NET????ask me...

eldo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:43 PM.

© 2006 - 2008 Net Business Talk Forums | About Net Business Talk Forums | Legal | A member of the Crowdgather Forum Community
 
 
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Designed by Vbulletinskinz.com