Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Help with connecting to a database in ASP
Old 06-10-2006, 08:48 PM Help with connecting to a database in ASP
Super Talker

Posts: 116
Trades: 0
Hey there,

I'm really rusty with connecting to a database via ASP "classic". I usually do this in PHP.

I'm building a newsletter archive system. I created the table in MS-SQL on a remote server. When a person clicks a certain month, I want the listing of the articles to appear into an asp page.

Because the tables are on a remote server, I believe I have to use a dsn-less connection.

I wrote the original program in PHP. But my job wants to keep their pages in ASP. To connect via PHP here's what I do... (the "real names" have been changed to protect the innocent.)

$server="servername.hostingcompany.com";
$username="our_user_name";
$password="our_password";
$sqlconnect=mssql_connect($server, $username, $password);

$sqldb=mssql_select_db("databasename",$sqlconnect) ;
$sqlquery="SELECT article_field FROM table;";
$results= mssql_query($sqlquery);

I'm comfortable with creating and reading recordsets in ASP, it's just opening the proper connection.

Could anyone please help?

Thanks
Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-10-2006, 09:15 PM Re: Help with connecting to a database in ASP
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Code:
 set Connect = Server.CreateObject("ADODB.Connection")
 Connect_String = "PROVIDER=SQLOLEDB;Data Source=" & Server_Name & ";Initial Catalog=" & Server_DB & ";USER ID=" & DB_User_ID & ";PASSWORD=" & DB_Password;"
 Connect.Open Connect_String
Whereby you'd have to know the values for Server_Name ($server), DB_User_ID ($username), DB_Password ($password) and Server_DB (which isn't listed there, so you need to get that.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-11-2006, 03:08 PM Re: Help with connecting to a database in ASP
Super Talker

Posts: 116
Trades: 0
Adam,

Thanks. I have the information but it's to my job's server!

Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 06-11-2006, 03:48 PM Re: Help with connecting to a database in ASP
Super Talker

Posts: 116
Trades: 0
Oops Adam,

I'm getting an error code: Expected end of statement.

Here's what I typed in:

Connect_String = "PROVIDER=SQLOLEDB;Data Source=" & location.remoteserver.com & ";Initial Catalog=" & ourDBname & ";USER ID=" & ourUserName &";PASSWORD="& abc123;"

The little ^ is pointing exactly after the double-quote at the end of the password.

I'm sure I'm missing something.

Thanks
Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 06-11-2006, 03:55 PM Re: Help with connecting to a database in ASP
Super Talker

Posts: 116
Trades: 0
Adam,

Yep, it was me.

Thanks. I found out my problem... I wasn't calling my last variable correctly.

Thank you, thank you, thank you.

DonnaZ
DonnaZ is offline
Reply With Quote
View Public Profile
 
Old 06-12-2006, 04:55 PM Re: Help with connecting to a database in ASP
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Not that I really said much after posting the code, but you're welcome.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Help with connecting to a database in ASP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31338 seconds with 12 queries