Pls help with ASP

  • Hi,

    My developers are off today. I hope you can do this very quick. I need to create an ASP file that uses SSPI authentication connecting to a SQL box named DB1. Once connected it will issue SELECT CustomerID FROM Northwind..Orders

    and display the result in the browser. To make it simple, I want to have an ASP file that when I open it in IE I will see the result of SELECT CustomerID FROM Northwind..Orders; given server name = DB1.

    Thx.

  • Set dkrConnection = Server.CreateObject("ADODB.Connection")

    Set dkrResult = Server.CreateObject("ADODB.Recordset")

    dkrConnString = Application("driver=SQL Server;server=db1\steve;database=northwind")

    dkrConnection.Open dkrConnString

    dkrQuery = "select * from orders"

    ' Execute the query

    dkrResult.Open dkrQuery, dkrConnection

    if not dkrResult.EOF then

    response.write(dkrResult.fields("customerid").value)

    dkrResult.movenext

    end if

    set dkrResult = Nothing

    set dkrConnection = Nothing

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • Will only display first row

    do until dkrResult.EOF

    response.write(dkrResult.fields("customerid").value)

    dkrResult.movenext

    loop

    will show all rows

    Far away is close at hand in the images of elsewhere.
    Anon.

  • I prefer

    while not dkrResult.EOF

    response.write(dkrResult.fields("customerid").value)

    dkrResult.movenext

    wend

  • thx everyone.

    Happy Turkey.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply