Tips Station Asp.net Article Seo Articles
Tutorials Code Samples
›  Home
›  Mission
›  About us
›  Contact Us
›  Feedback
›  Terms & Condition
Asp Articles
IT Solutions
 
› ASP.NET

› Programming Tips

› Ajax

› Asp

› ADO.NET

› Databases

› SEO

› CSS And Designing

› Php

 
Most Viewed Articles
 
› Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

› Change theme dynamically without page refresh in ASP.NET

› Install AJAX On Machines Running Visual Studio 2005

› Creating Pretty Popups Using AJAX

› Simple ASP Image Resize Function

› SQL Server Performance Counters

› ASP.Net Interview Questions And Their Answers

› Encode Url using ASP

› Difference Between DataGrid and GridView in Asp.Net

› Select Specific Value WithIn Drop Down List Or Radio Button List

more...
 
 
Home> Asp
 
How to connect to a database via a DSN-Less connection - ASP
 

Here is what the code looks like:

Dim oConn, sConnString
Set oConn = Server.CreateObject("ADODB.Connection")
sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("\MemberName\db\dbname.mdb") & ";"
oConn.Open(sConnString)

At this point you can define a SQL statement and execute it:

sql = "select * from myTable"
Set RS = Conn.Execute(sql)

The components of the DSN-Less connection explained:

First we instantiate the Connection Object:

Set Conn = Server.CreateObject("ADODB.Connection")

Next we define the actual connection string:

sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("\MemberName\db\dbname.mdb") & ";"

Make sure the above line of code is all on one line in your code, don't wrap it. In this statement we are telling ADO (Active Data Objects) that we want to use the MS Access driver and where our database is physically located.

Conn.Open(MyConnStr)

This is the line of code that actually opens the connection to the database. After you have done this you are ready to execute a SQL statement.

 
 
Vrp Technologies
 
Serversea Hosting
 
 
Latest Articles
 
› Sending SMS With PHP

› MySQL Join Tutorial

› Make An RSS Feed Using PHP

› Intro To Object: Option Variables

› Design An Online Chat Room With PHP And MySQL

› Create Tell A Friend Script With HTML & PHP

› Benchmark And Optimize PHP Script Speed

› What Kind of DBA Are You?

› SQL Server Performance Counters

› SQL Server Performance Tips

more...
 
Random Articles
 
› Creating Pretty Popups Using AJAX

› Difference Between DataGrid and GridView in Asp.Net

› ASP.Net Tips and Tricks

› .NET Data Access Performance Comparison

› How to export a GridView to Excel - Asp.net

› The Most Powerful SEO Tactic: Simplify, Simplify, Simplify

› CSS Cursors - How To Use Them

› Understanding Transaction in ADO.NET

› Understanding VARCHAR(MAX) In SQL Server 2005

› Alternating Row Colors

more...
 
Home Mission About us Contact us Feedback Terms Conditions
2008 © Copyright TipsStation. All rights reserved.