欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          asp如何調(diào)用mysql數(shù)據(jù)庫

          asp調(diào)用mysql數(shù)據(jù)庫的方法:首先安裝mysql odbd的驅(qū)動程序,將下載的【myodbd-2.50.46-dll】文件復制到【windowssystem】目錄下;然后建立asp文件鏈接數(shù)據(jù)庫即可。

          asp如何調(diào)用mysql數(shù)據(jù)庫

          本教程操作環(huán)境:windows7系統(tǒng)、mysql3.23.32版,該方法適用于所有品牌電腦。

          相關(guān)學習推薦:mysql數(shù)據(jù)庫

          asp調(diào)用mysql數(shù)據(jù)庫的方法:

          第一步:安裝mysql odbd的驅(qū)動程序,將下載的myodbd-2.50.46-dll文件復制到windowssystem目錄下(windows2000是winnt/system32)

          然后建立一新文件,擴展名為reg(就是注冊表文件),將以下內(nèi)容復制到該文件中。

          regedit4 [hkey_local_machinesoftwareodbcodbcinst.inimyodbc driver] "usagecount"=dword:00000002 "driver"="c:\windows\system\myodbc.dll" "setup"="c:\windows\system\myodbc.dll" "sqllevel"="1" "fileusage"="0" "driverodbcver"="02.50" "connectfunctions"="yyy" "apilevel"="1" "cptimeout"="120" [hkey_local_machinesoftwareodbcodbcinst.iniodbc drivers] "myodbc driver"="installed"

          保存后雙擊該文件,將上面代碼注冊到windows注冊表中。

          如果安裝在windows2000中,則driver和setup主鍵的值要做相應改變,這里我想就不用多說了。

          如果成功,在控制面板/odbd數(shù)據(jù)源的驅(qū)動程序里將看到myodbd driver這一項!

          第二步:建立asp文件鏈接數(shù)據(jù)庫。

          這里有兩種方法,一種是在odbc數(shù)據(jù)源中建立一個系統(tǒng)dsn。后來我發(fā)現(xiàn)不建立也可以在asp中使用mysql,方法在下文將講道。

          打開控制面板/odbd數(shù)據(jù)源,選擇系統(tǒng)dsn,然后添加一個新的dsn,驅(qū)動程序選擇myodbd driver,會出現(xiàn)一個對話框供輸入mysql

          相關(guān)信息。

          • windows dsn name: 所要建立dsn的名稱

          • mysql host (name or ip):mysql服務(wù)器的名稱或者是ip地址,通常填localhost

          • mysql database name:需要使用數(shù)據(jù)庫的名稱,數(shù)據(jù)庫在mysql管理程序中建立。

          這里我們使用一個例子。

          數(shù)據(jù)庫名:hc188里面有數(shù)據(jù)表,

          user 數(shù)據(jù)表有兩個字段分別是:username和password,隨便插入幾個數(shù)據(jù)。

          • user:鏈接數(shù)據(jù)庫的用戶名,我填的是root超級用戶

          • password:鏈接數(shù)據(jù)庫用戶密碼,如果沒有,可以不填

          • port(if not 3306):mysql在服務(wù)器的端口,如果不填默認為3306

          • sql command on connect:使用sql命令鏈接數(shù)據(jù)庫,這項可以不填

          填寫完畢后選擇ok保存。

          下面鏈接數(shù)據(jù)庫的asp代碼!

          <% strconnection = "dsn=hc188;driver={myodbd driver};server=localhost;uid=root;pwd=;database=hc188" set adodataconn = server.createobject("adodb.connection") adodataconn.open strconnection strquery = "select * from user" set rs = adodataconn.execute(strquery) if not rs.bof then %> <table> <tr> <td<b>username</b></td> <td><b>password</b></td> </tr> <% do while not rs.eof %> <tr> <td><%=rs("username")%></td> <td><%=rs("password")%></td> </tr> <% rs.movenext loop %> </table> <% else response.write("sorry, no data found.") end if rs.close adodataconn.close set adodataconn = nothing set rsemaildata = nothing %>

          第二種方法:我在使用中想過如果不建立系統(tǒng)dsn,是否也可以使用mysql數(shù)據(jù)庫呢?結(jié)果是可以的。

          方法很簡單,把上面asp代碼第二行代碼改為:

          strconnection="defaultdir=;driver={myodbc driver};database=hc188"

          我奇怪的發(fā)現(xiàn),這種方法連用戶名和密碼都不需要就可以使用。是不是mysql的一個bug呢?

          以上代碼全部經(jīng)測試通過!

          相關(guān)免費學習推薦:php編程(視頻)

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號