473,385 Members | 1,528 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,385 software developers and data experts.

Connection string declarations

I'm using a connection string in my asp pages similar to:

cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"
set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Do I need to declare the cst and conn variables?

ie:

dim cst
cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"

dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Thanks
Jul 19 '05 #1
2 10532
Check this out and then decide (it *is* optional but recommended to declare
variables and use 'Option Explicit').

http://www.4guysfromrolla.com/webtec...ate/faq6.shtml

Chris.

"Luis" <an****@webmail.co.za> wrote in message
news:69**************************@posting.google.c om...
I'm using a connection string in my asp pages similar to:

cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"
set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Do I need to declare the cst and conn variables?

ie:

dim cst
cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"

dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Thanks
Jul 19 '05 #2
-----Original Message-----
I'm using a connection string in my asp pages similar to:

cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;
"cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Do I need to declare the cst and conn variables?

ie:

dim cst
cst = "Provider=SQLOLEDB;Server=MyServerName;Database=My DbName;
"cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"
dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.open cst

Thanks
.

I dont bother creating a connection string variable at all
unless I intend to use it twice, so you could get away
with -
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=SQLOLEDB;Server=MyServerName;Databas e=M
yDbName;Network Library=DBMSSOCN;User
ID=MyUserid;Password=MyPass"

HTH,

Colin
Jul 19 '05 #3

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

Similar topics

6
by: Chris Connett | last post by:
I have an interesting problem with eval(). ---Background Info--- The program I'm working on launches a separate process with a popen to do some highly specialized processing of input, then this...
10
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is...
3
by: tperovic | last post by:
Hi, I have an application that uses ADO & VBA to connect to SQL Server 2000 periodically like this: Dim conn As ADODB.Connection Set conn = New ADODB.Connection conn.ConnectionTimeout = 1...
10
by: Lars Netzel | last post by:
Hi! Is it possible to start a dial-up connection that is already created on the computer thru VB.NET, and then after it has dialed up get an idication of that there's a connection ( I guess ping...
5
by: Frank Rizzo | last post by:
This is driving me nuts. I call the InternetDial API to open a dial-up connection and it just returns 0 (success) without actually making a call. Am I missing something really simple? I've tried...
5
by: Paul W Smith | last post by:
My application uses two ways to connect to the Access db: Programtically: Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;" Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" &...
5
by: vieraci | last post by:
Hi, I'm wanting to start a database connection at the start of an app and keep it open for all methods and classes that I'm #including in my project. First I went about it by creating the...
3
by: puzzlecracker | last post by:
What I currently have and request a suggestion to modularize it public sealed class Connection: BaseConnection{ //I have to process about 30 events public event Handler1=handler1; public...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.