asp連接access數(shù)據(jù)庫代碼(win10 asp連接access數(shù)據(jù)庫)
rem === rem 函數(shù)名ConnData rem 作 用鏈接數(shù)據(jù)庫 rem 參 數(shù)databasetype=鏈接類型,access用ac,其他就按照sql鏈接 rem 參 數(shù)db_name=數(shù)據(jù)庫名 rem 參 數(shù)db_user=sql登錄賬號 rem 參 數(shù)db;添加刪除比較簡單,修改查找相對復雜一點,一般來說就是按照SQL的相關(guān)語句來寫。
lt set conn=servercreateobjectquotadodbconnectionquotconnopen quotdriver=microsoft access driver *mdbdbq=quotservermappathquotexample3mdbquot 第一句話定義了一個adodb數(shù)據(jù)庫連接組件,第二句連接了數(shù)據(jù)庫,大家;sender,SystemEventArgs e打開數(shù)據(jù)庫 private void Page_Loadobject sender,SystemEventArgs e MyConnectionOpen 在此處放置用戶代碼對數(shù)據(jù)庫進行增加刪除修改查詢等操作 MyConnectionClose。
asp連接access數(shù)據(jù)庫不成功
第一種方法,就是真接在在設(shè)計頁面上拉一個控件,例如GridViewDataList,點擊右上角那個三角符,新建數(shù)據(jù)源,在跳出的對話框選擇數(shù)據(jù)庫,新建連接,在添加連接對話框的更改那里選擇Access數(shù)據(jù)庫,之后在瀏覽那里選擇你的數(shù)據(jù)。
通常,用這個連接AC dim conn,MyDbPath dim connstr,db db=quotydataxiaoxianaspquot #39數(shù)據(jù)庫目錄和名 MyDbPath = quotquoton error resume next #39繼續(xù)執(zhí)行 set conn=servercreateobjectquotADODBCONNECTIONquotConnStr = quot。
win10 asp連接access數(shù)據(jù)庫
而我們在一般情況下使用Access的數(shù)據(jù)庫比較多,在這里我建議大家連接Access數(shù)據(jù)庫使用下面的方法dim conn set conn = servercreateobjectquotadodbconnectionquotconnopen = quotprovider=quot quotdata。
lt% dim conn,mdbfile mdbfile=servermappathquot數(shù)據(jù)庫名稱mdbquot set conn=servercreateobjectquotadodbconnectionquot connopen quotdriver=microsoft access driver *mdbuid=adminpwd=數(shù)據(jù)庫密碼dbq=quotmdb。
Const SystemDatabaseType = quotACCESSquot #39系統(tǒng)數(shù)據(jù)庫類型,quotSQLquot為MS SQL2000數(shù)據(jù)庫,quotACCESSquot為MS ACCESS 2000數(shù)據(jù)庫 #39如果是ACCESS數(shù)據(jù)庫,請認真修改好下面的數(shù)據(jù)庫的文件名 Const DBFileName = quot\database\SiteWeave。
第三行程序利用連接對象Conn的Open方法打開一個指定的數(shù)據(jù)庫因為我們要打開的是Access數(shù)據(jù)庫,所以要指定ODBC驅(qū)動程序參數(shù),表示要透過Access的ODBC驅(qū)動程序來訪問數(shù)據(jù)庫driver=Microsoft Access Driver *mdb另一個。
打開數(shù)據(jù)連接 連接所有的數(shù)據(jù)庫都要先建立數(shù)據(jù)的連接對象和記錄集對象,要就是connection和recordset ,connopen后面的語句是數(shù)據(jù)庫引擎,有幾種寫法,你這是一種,還有就是sql數(shù)據(jù)庫和access的連接代碼是不是一樣的 建立。
這段話是asp連接數(shù)據(jù)庫的代碼,意思是你要先建一個名字叫datamdb的數(shù)據(jù)庫文件在你的。
掃描二維碼推送至手機訪問。
版權(quán)聲明:本文由飛速云SEO網(wǎng)絡(luò)優(yōu)化推廣發(fā)布,如需轉(zhuǎn)載請注明出處。