Problems connecting to SQL Data Source

Author Message
shaun_wells

  • Total Posts : 16
  • Scores: 0
  • Reward points : 0
  • Joined: 2/25/2008
  • Status: offline
Problems connecting to SQL Data Source Thursday, January 15, 2009 10:45 PM (permalink)
0
Hi, This is my first script trying to connect to a SQL database..
 
The script is below, the problem I'm having is that the Response.write(ObjConnection.State) & Response.write(ObjConnection.Provider) do not provide me any information when run as an asp file..
 
Questions I have, does the code look correct.. Should this be saved as an asp page or htm.. Why can't I see if the connection has been established.. As I'm not getting any results back.. Thanks
 
 
 
<html>
<head>Users</head>
<body>
<%
    'Opens Connection to the Data Source
    Set ObjConnection = CreateObject("ADODB.Connection") 
   
    ' String required to connect to the data source (intergrated or defined username and password)      
    
 Str = "Driver={SQL Server};Server=IBLONPSD32X633\OI_DEV3;Database=malign_prod;UID=x;PWD=x;" 
      
    'Opens Connections to above SQL Database
      
    ObjConnection.Open Str
   
    Response.Write(ObjConnection.State)
   
    Response.Write(ObjConnection.Provider)
       
    'Opens Connection to RecordSet
   
    Set objRecordSet = CreateObject("ADODB.RecordSet")
   
    'Run a SQL query against the opened RecordSet  
    
    objRecordSet.Open "select * from pluser", ObjConnection
   
    %>
   
<table border="1" width="100%">
   
 <%do until ObjRecordSet.EOF%> 
     
 <tr>
 
      <%For Each x In ObjRecordSet.Fields%> 
           
 
     <td><%Response.write(x.value)%></td>
     
      
          
    <%Next
   
    ObjRecordSet.MoveNext%>
   
  </tr>
   
<%Loop
ObjRecordSet.Close
ObjConnection.Close%>
</table>
</body>
</html>
 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    RE: Problems connecting to SQL Data Source Sunday, January 18, 2009 5:23 AM (permalink)
    0
    worked for me...

    file must have an ".asp" extension...

    I have this as my connection string

    ServerName="xxxx"
    UID="xxxx"
    passwd="xxxx"
    dbName="xxxxx"

    Str = "Provider=SQLOLEDB;Data Source=" & ServerName & ";UID=" & UID & ";PWD=" & Passwd & ";DATABASE=" & dbName & ""

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9