SQLDMO.SQLServer
The code for the SQLDMO.SQLServer object should look very familiar. It allows you to connect to a given SQL server using either SQL Server on Windows NT authentication. Take a look at the snippet below.
<% Dim srv Set srv = Server.CreateObject("SQLDMO.SQLServer") srv.LoginTimeout = 15 srv.Connect "servername", "username", "password" %>
This code creates a connection to SQL Server using SQL Server authentication. To login using NT authentication set the LoginSecure property to TRUE. This will cause the username and password parameters to be ignored and your NT login information will be used.
SQLDMO.Database
We will use the SQLDMO.Database object to get a list of databases from the server. This information is used to complete a backup request form in the sample application. The snippet below demonstrates using this object to populate a combo box.
<% Dim srv Dim objDB Set srv = Server.CreateObject("SQLDMO.SQLServer") srv.LoginTimeout = 15 srv.Connect "servername", "username", "password" Set objDB = Server.CreateObject("SQLDMO.Database") %><SELECTname="fdatabase"><%For Each objDB In srv.Databases If objDB.SystemObject = FalseThen%><OPTION><%=objDB.Name%></OPTION><%End IfNext%></SELECT>
Comments