|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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
|
|
#3
|
|||
|
|||
|
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?
|
|
#4
|
||||
|
||||
|
place the global.asa file in the root of the website, where you would have your index.asp or default.asp page.
|
|
#5
|
|||
|
|||
|
thanks a bunch
|
|
#6
|
|||
|
|||
|
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] |
|
#7
|
|||
|
|||
|
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.
|
|
#8
|
|||
|
|||
|
thanks, but I actually just got it working, I had a security issue with SQL Server.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > simple connection question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|