Web Design and Development Forums

[SOLVED] Easiest way to open database connection!

This is a discussion on "[SOLVED] Easiest way to open database connection!" within the MSSQL & Access section. This forum, and the thread "[SOLVED] Easiest way to open database connection! are both part of the Databases category.


Go Back   Webforumz.com > Databases > MSSQL & Access

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Sep 27th, 2007, 09:05   #1 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,560
Blog Entries: 2
Send a message via Yahoo to Monie
[SOLVED] Easiest way to open database connection!

Hai,

I was wondering if you guys have a "short-cut" or "simplest easiest way" on how to connect to the database and declare the recordset!

Typically, people will do like this:

Code: Select all
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>
<body>
..
..
</body>
<%
rs.close
conn.close
%>
or maybe some thing like this:

External Connection:
Code: Select all
<%
Dim MM_connInvoice_STRING
MM_connInvoice_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../db/product.mdb")
%>
index.asp
Code: Select all
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/connInvoice.asp" -->

<%
Dim rsCustomers
Dim rsCustomers_cmd
Dim rsCustomers_numRows

Set rsCustomers_cmd = Server.CreateObject ("ADODB.Command")
rsCustomers_cmd.ActiveConnection = MM_connInvoice_STRING
rsCustomers_cmd.CommandText = "SELECT * FROM tblCustomer ORDER BY CName ASC" 
rsCustomers_cmd.Prepared = true

Set rsCustomers = rsCustomers_cmd.Execute
rsCustomers_numRows = 0
%>
Thanks..
__________________


Last edited by Monie; Sep 27th, 2007 at 09:07.
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Oct 19th, 2007, 08:39   #2 (permalink)
Junior Member
 
Join Date: Aug 2007
Location: UK
Posts: 13
Re: Easiest way to open database connection!

I tend to use the same type of code as youv'e indicated and don't know of a better method.
Rob
thriftyspider is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Oct 19th, 2007, 08:43   #3 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,560
Blog Entries: 2
Send a message via Yahoo to Monie
Re: Easiest way to open database connection!

Thanks Rob,

Well, I have done my own research and now I understand which one to use.

[ Here ]
__________________

Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Oct 20th, 2007, 11:04   #4 (permalink)
Junior Member
 
Join Date: Aug 2007
Location: UK
Posts: 13
Re: Easiest way to open database connection!

Hi again, just found this site http://www.connectionstrings.com/ might come in handy should you decide to use sql server, mySql etc.

Rob
thriftyspider is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Nov 1st, 2007, 07:35   #5 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,560
Blog Entries: 2
Send a message via Yahoo to Monie
Re: Easiest way to open database connection!

I don't have problem with the connection string actually..
Just a question in doing some effective way of coding certain things..

Thanks by the way for that link.
__________________

Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Database Connection Error Message Monie ASP Forum 6 Nov 2nd, 2007 08:08
Connection to access database thriftyspider Java, JSP, Cold Fusion 1 Aug 7th, 2007 20:41
Database connection fogofogo ASP Forum 7 Dec 5th, 2005 14:25
another database connection question! asp and mysql fogofogo ASP Forum 4 Dec 2nd, 2005 08:48
Database Connection Strings Smokie ASP Forum 0 Aug 7th, 2003 09:51



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 21:41.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
SEO by vBSEO 3.1.0


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59