Connection string declarations

L

Luis

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

cst = "Provider=SQLOLEDB;Server=MyServerName;Database=MyDbName;"
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=MyDbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"

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

Thanks
 
C

Chris Barber

Check this out and then decide (it *is* optional but recommended to declare
variables and use 'Option Explicit').

http://www.4guysfromrolla.com/webtech/faq/Intermediate/faq6.shtml

Chris.

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

cst = "Provider=SQLOLEDB;Server=MyServerName;Database=MyDbName;"
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=MyDbName;"
cst = cst & "Network Library=DBMSSOCN;User ID=MyUserid;Password=MyPass"

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

Thanks
 
G

Guest

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

cst
= "Provider=SQLOLEDB;Server=MyServerName;Database=MyDbName;
"
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=MyDbName;
"
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;Database=M
yDbName;Network Library=DBMSSOCN;User
ID=MyUserid;Password=MyPass"

HTH,

Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top