Connect SQL database through ASP

From: Sheridan (anonymous_at_discussions.microsoft.com)
Date: 07/03/04

  • Next message: peter: "Re: Communciation between MS SQL Server and client"
    Date: Sat, 3 Jul 2004 08:23:16 -0700
    
    

    I have SQL Server 2000 installed on my machine and tried
    to develop asp script to connect to the server database
    (localhost). But I got invalid authorization error
    message, any help will be greatly appreciated. Following
    is my script:

    <%Option Explicit%>
    <html>
    <head>
    <title>Testing Connection1</title>
    </head>
    <body>

    <%
    Dim strConnectionString
    strConnectionString = "Provider=SQLOLEDB.1;Data
    Source=C:\Program Files\Microsoft SQL
    Server\MSSQL\Data\Master.mdf"

    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objConn.Open strConnectionString

      strSQL = "SELECT First_Name, Last_Name FROM
    Member_Master"
      objRS.Open strSQL, objConn

       Set objFirstName = objRS("First_Name")
       Set objLastName = objRS("Last_Name")
       Do Until objRS.EOF
         Response.Write objFirstName & " " & objLastName
    & "<BR>"
         objRS.MoveNext
       Loop

    objRS.Close
    objConn.Close
    Set objRS = Nothing
    Set objConn = Nothing
    %>

    </body>
    </html>
    ------

    Thanks,
    Sheridan


  • Next message: peter: "Re: Communciation between MS SQL Server and client"

    Relevant Pages

    • Re: Problems retrieving image from SQL server
      ... display it on an ASP page. ... Set objConn = Server.CreateObject ... Set objRS = Server.CreateObject ... The original images were added to SQL server through an Access front end, ...
      (microsoft.public.inetserver.asp.db)
    • Re: FOR XML AUTO - Cutting off XML
      ... > I'm using Classic ASP with SQL Server to read in XML data. ... > If I return about 5 records everything seems fine but returning 10 records,> the XML seems to cut off towards the end. ... > Set objConn = Server.CreateObject ... > Set objRS = Server.CreateObject> objRS.Open strSQL, ...
      (microsoft.public.sqlserver.programming)
    • FOR XML AUTO - Cutting off XML
      ... I'm using Classic ASP with SQL Server to read in XML data. ... Set objConn = Server.CreateObject ... Set objRS = Server.CreateObject ...
      (microsoft.public.sqlserver.programming)
    • Re: error no record
      ... : Dim UserName ... : 'Create the recordset object ... Set objRS = Nothing ... Set objConn = Nothing ...
      (microsoft.public.scripting.vbscript)
    • Re: error no record
      ... >:I made a script, that connect to a sql server db, and made a query. ... > 'Tidy up the objects ... > Set objRS = Nothing ... > Set objConn = Nothing ...
      (microsoft.public.scripting.vbscript)