ASP access to DBMS
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?
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';"
' 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
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)