www.webdeveloper.com
Results 1 to 2 of 2

Thread: ASP access to DBMS

  1. #1
    Join Date
    Dec 2002
    Posts
    44

    ASP access to DBMS

    Hi guys,

    I recently found a host that offers SQL Server as part of their hosting deal, but they state that you can only access it via ASP scripts, and not by using ODBC, OLEDB etc. Does ASP have its own connective technology?

    I have used ASP but I have always used either ODBC or OLEDB for backend connection, so their response seems a bit odd to me. So, does anyone know how it is possible to access a backend DBMS using ASP scripts exclusively?

    Cheers

  2. #2
    Join Date
    Dec 2002
    Posts
    54
    HI,
    May be what they want to say that you can not connect the DB using DSN(User,file or system). you have to connect the DB using DSN less connection and using native interfaces in ASP. Here is a sample code. Try this out:
    --------------------------------------
    <% ' to integrate/test this code replace the
    ' Data Source value in the Connection string%>
    <%
    ' connection and recordset variables
    Dim Cnxn, strCnxn
    Dim rsCustomers, strSQLCustomers
    Dim rsProducts, strSQLProducts

    ' open connection
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider='sqloledb';Data Source=" & _
    Request.ServerVariables("SERVER_NAME") & ";" & _
    "Integrated Security='SSPI';Initial Catalog='Northwind';"

    Cnxn.Open strCnxn

    ' create and open first Recordset using Connection - execute
    Set rsCustomers = Server.CreateObject("ADODB.Recordset")
    strSQLCustomers = "SELECT CompanyName, ContactName, City FROM Customers"
    Set rsCustomers = Cnxn.Execute(strSQLCustomers)

    ' create and open second Recordset using recordset - open
    Set rsProducts = Server.CreateObject("ADODB.Recordset")
    strSQLProducts = "SELECT ProductName, UnitPrice FROM Products"
    rsProducts.Open strSQLProducts, Cnxn, adOpenDynamic, adLockPessimistic, adCmdText
    %>
    ----------------------------
    Vishal Gupta

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles