Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 9th, 2003, 08:51 PM
safranko safranko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: STL
Posts: 12 safranko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 9 sec
Reputation Power: 0
simple connection question

I'm new to the SQL Server and asp realm, I've worked with Access, but needed more to my database interaction. Anyways, I'm trying to connect to my database and can't seem to get it to work. I set up a DSN, and my permissions all look ok. I was curious if someone could show me the connection string I would use for this. Please keep it simple, I've been looking at tons of links and I still haven't found one that was successful.
Thanks.

Reply With Quote
  #2  
Old December 9th, 2003, 09:00 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 18 m 17 sec
Reputation Power: 443
In your global.asa file
Code:
Sub Application_OnStart
   Application("ConnectionString") = "Driver={SQL Server};Server=serverName;UID=username;PWD=passwor  d;Database=dbname;"
End Sub


To connect to the database, query a table and return the records
Code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("ConnectionString")
Set getRows = Conn.Execute("SELECT * FROM tableName")

do until getRows.eof
     Response.Write(getRows("TABLE_NAME") & "<br>")
     getRows.movenext
loop

Conn.Close

Reply With Quote
  #3  
Old December 9th, 2003, 09:33 PM
safranko safranko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: STL
Posts: 12 safranko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 9 sec
Reputation Power: 0
thanks so much, now do i need to put the global.asa file anywhere special, or do anything else to get it working, or is that it?

Reply With Quote
  #4  
Old December 10th, 2003, 08:39 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 18 m 17 sec
Reputation Power: 443
place the global.asa file in the root of the website, where you would have your index.asp or default.asp page.

Reply With Quote
  #5  
Old December 10th, 2003, 04:50 PM
safranko safranko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: STL
Posts: 12 safranko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 9 sec
Reputation Power: 0
thanks a bunch

Reply With Quote
  #6  
Old December 10th, 2003, 05:03 PM
safranko safranko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: STL
Posts: 12 safranko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 9 sec
Reputation Power: 0
ok, still not working, it says:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/test.asp, line 11



here's my global.asa file:
---------------------------------
Sub Application_OnStart
Application("ConnectionString") = "Driver={SQL Server};Server=WIREDSERVER;UID=user;PWD=welcome;Da tabase=WiredSociety;"
End Sub


And here's my test page:
--------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("ConnectionString")
Set getRows = Conn.Execute("SELECT * FROM Users")

do until getRows.eof
Response.Write getRows("Username")
getRows.movenext
loop
Conn.Close
%>
</body>
</html>[COLOR=darkblue]

Reply With Quote
  #7  
Old December 10th, 2003, 06:03 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 12 m 35 sec
Reputation Power: 180
MyODBC needs to be installed on the web server. In addition, the current v3.51 ODBC driver for MySQL has a slightly different connection string syntax. Visit www.mysql.com and view the MyODBC documentation for examples of using the MyODBC driver.

Reply With Quote
  #8  
Old December 10th, 2003, 06:13 PM
safranko safranko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: STL
Posts: 12 safranko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 9 sec
Reputation Power: 0
thanks, but I actually just got it working, I had a security issue with SQL Server.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > simple connection question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway