inf : http://support.microsoft.com/kb/169377
- install sql server with sql authorization logon
- create system.dsn
- create Global.asa file in iis. (syntax)
- now it can create example.asp file to run it.
with sql authorization logon
sqlServer Name
create system.dsn
Global.asa
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
Session("ConnectionString") =
"DSN=DEMO;UID=<username>;PWD=<strong password>;DATABASE=pubs;APP=ASP script"
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub
Sub Session_OnEnd
End Sub
</SCRIPT>
example.asp
<HTML>
<HEAD>
<TITLE>All Authors</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<% Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.ConnectionTimeout = Session("ConnectionTimeout")
OBJdbConnection.CommandTimeout = Session("CommandTimeout")
OBJdbConnection.Open Session("ConnectionString")
Set SQLStmt = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject ("ADODB.Recordset")
%>
<p>
<table border="0" bordercolor="#000000">
<%
SQLStmt.CommandText = "select * from authors"
SQLStmt.CommandType = 1
Set SQLStmt.ActiveConnection = OBJdbConnection
RS.Open SQLStmt
Do While Not RS.EOF
%>
<TR>
<TD Width = 150 ALIGN=LEFT>
<FONT SIZE=+1>
<%= RS("au_id") %>
</FONT></TD>
<TD></TD>
<TD Width = 150 ALIGN=LEFT>
<FONT SIZE=+1>
<%= RS("au_lname") %>
</FONT></TD>
<TD Width = 150 ALIGN=LEFT>
<FONT SIZE=+1>
<%= RS("au_fname") %>
</FONT></TD>
<TD Width = 150 ALIGN=LEFT>
<FONT SIZE=+1>
<%= RS("phone") %>
</FONT></TD>
</TR>
<%
RS.MoveNext
Loop
%>
</table>
<hr>
<p>
</BODY>
<% OBJdbConnection.Close
Set OBJdbConnection = Nothing
%>
</HTML>






沒有留言:
張貼留言