aspÁ¬½ÓMssqlµÄ·½·¨¼°³£¼ûµÄ´íÎó
aspÏνÓMssqlµÄ°ì·¨¼°³£¼ûµÄ²î´í
//µÚÒ»ÖÖд·¨£º
MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3
//µÚ¶þÖÖд·¨£º£¨DSNÏνӣ©
MM_conn_STRING="DSN=BBS;UID=SA;PWD=12345"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3 // 3,3ÊǸĶ¯¡¢É¾³ý¡¢ÔöÌí¿ª¹Ø£¡
//µÚÈýÖÖд·¨£º
MM_conn_STRING_own = "Driver={SQL Server};server=(local);uid=sa;pwd=11111;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING_own
//µÚËÄÖÖ - ÕâÖÖ·½Ê½ÓÃÔÚACCESSÖÐ
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" _
& Server.MapPath("asp.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
ʵÏÖ·½Ê½Ò»:
<%
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=(local);UID=Óû§Ãû;PWD=ÃÜÂë;DATABASE=Êý¾Ý¿â"
Set conn = Server.CreateObject("ADODB.Connection")
DSNtemp="DRIVER={SQL Server};SERVER=(local);UID=Óû§Ãû;PWD=ÃÜÂë;DATABASE=Êý¾Ý¿â"
conn.open DSNtemp
%>
ʵÏÖ·½Ê½¶þ:
<%
option explicit
dim startime
dim conn
dim connstr
dim db,pass_word,User_ID,Data_Source
startime=timer()
db="Êý¾Ý¿âÃû³Æ"
Pass_word="ÕʺÅÃÜÂë"
User_ID="µÇ½ÕʺÅ"
Data_Source="·þÎñÃû³Æ»òÕßip"
Set conn = Server.CreateObject("ADODB.Connection")
connStr="Provider=SQLOLEDB.1;Password='"&pass_word&"';Persist Security Info=True;User ID='"&User_ID&"';Initial Catalog='"&db&"';Data Source='"&Data_Source&"'"
conn.Open connstr
function CloseDb
Conn.close
Set conn = Nothing
End Function
³£¼û¹ÊÕÏ
(a)
Microsoft OLE DB Provider for ODBC
Ïà¹ØÎĵµ£º
<%
Const New_img=10
set rs_Product=server.createobject("adodb.recordset")
sqltext="select top " & New_img & " * from 0791idc_Product order by ID"
rs_Product.open sqltext,conn,1,1
if not rs_Product.EOF then%>
<div align='center' id='demo' style='o ......
Õ⼸ÌìºÃ¶àÈËÎÊÎÒÈçºÎÔÚasp³ÌÐòÖпØÖÆÉãÏñÍ·È¥×¥ÅÄÕÕƬ£¬asp¼¼Êõ»¹ÊÇ99ÄêµÄʱºò¿´¹ýÒ»µãµã£¬Ôç¾Í×ÅÃ×·¹³ÔÁË£¬²»¹ý¼ÈÈ»ÓÐÈËÎÊ£¬ÄǾÍÊÇ¿´µÃÆðÔÛ£¬»¨ÁËÒ»¸öÍíÉϵÄʱ¼ä°Ñasp³ÌÐòµ÷ÓÃÉãÏñÍ·ÅÄÕÕµÄÎÊÌâ¸ã¶¨ÁË£¬ÏּǼÈçÏ£¬ÈÃÓÐÀàËÆÐèÇóµÄͬѧ¿ÉÒÔÉÙ×ßЩÍä·¡£
Óõ½µÄ¼¼Êõ£º
1.asp³ÌÐòÖÐ×÷base64±àÂëºÍ½âÂ룬ʹÓõÄÊÇmsxml×é¼þ£ ......
<%
for i=1 to rs.recordCount '±äÁ¿i´Ó1Ñ»·µ½Êý¾Ý¿âÖеÄÈ«²¿¼Ç¼Êý
if (i mod 1 =1) then 'ÿ¸ötr¼´Ã¿ÐÐÏÔʾ1¸ö¼Ç¼,¿É¸ù¾ÝÐèÒª×ÔÐÐÐÞ¸Ä, ½«×ó±ßµÄ1ÐÞ¸ÄΪ2¼´ÏÔʾÁ½ÐС£
response.write "<tr align='center'>"
end if
%>
´Ë´¦ÎªÒªÑ»·µÄÄÚÈÝ
<%if (i mod 1 = 0) then ......
Adodb.StreamÊÇADOµÄStream¶ÔÏó,Ìṩ´æÈ¡¶þ½øÖÆÊý¾Ý»òÕßÎı¾Á÷,´Ó¶øʵÏÖ¶ÔÁ÷µÄ¶Á¡¢Ð´ºÍ¹ÜÀíµÈ²Ù×÷.
ÓÐÏÂÁз½·¨£º
Cancel ·½·¨
ʹÓ÷½·¨ÈçÏÂ
Object.Cancel
˵Ã÷£ºÈ¡ÏûÖ´ÐйÒÆðµÄÒì²½ Execute »ò Open ·½·¨µÄµ÷Óá£
Close ·½·¨
......
Õ⼸Ììѧϰ¶¯Ì¬ÍøÕ¾µÄÖÆ×÷£ºASP¡£ÓÉÓÚÀÏʦ½²µÄºÜÈÏÕ棬ºÜÏêϸ£¬¿Î³ÌÄÜÌý¶®£¬×Ô¼ºÒ²ÂòÁËÒ»±¾¹ØÓÚASPµÄÊé¼®£¬ASPµÄһЩ¹¦ÄܵÄʵÏÖ£¬Ôõô×ö³öÀ´ÄÜ¿´µÄ²î²»¶à£¬¿É¾ÍÊÇ×öµÄʱºòºÃ²î¾¢£¬²»ÊÇij¸öÓ¢Óïµ¥´Ê²»»áд£¬¾ÍÊÇÖظ´´íÎó³öÏÖ£¬Éî¿ÌµÄÃ÷°×£¬×öÍøÕ¾ÔÀ´ÕâôÄÑ£¬²»½öÐèÒªÑϽ÷µÄÂ߼˼άÄÜÁ¦£¬¶ø ......