ユニバーサルデータベースクライアントは、ユニバーサルデータベース接続プログラムを学習します。このデータベースクライアントは、データベースカバレッジと表示できるすべてのデータベースをサポートするユニバーサルデータベースクライアントであると言えます。それで、あなたはユニバーサルデータベース接続プログラムを知っていますか? Foot New Technologyチャンネルの編集者に、それについてもっと学びましょう!
はじめに:データベース操作用のさまざまな種類のデータベースと機能を接続する
次のプログラムは、ほぼすべてのMSデータベースに接続できるユニバーサルデータベース接続プログラムであると言えます。自分で調査するために使用してください(このプログラムは本「ASP Webページ制作チュートリアル」 - 良い本にあります):
<%
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getMdbConnection(filename)
DIMプロバイダー、DBPATH
Provider = "provider = microsoft.jet.oledb.4.0;"
dbpath = "data source ="&server.mappath(filename)
getmdbconnection = getConnection(Provider&DBPath)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getSecuredMDBConnection(filename、password)
DIMプロバイダー、DBPATH
Provider = "provider = microsoft.jet.oledb.4.0;"
dbpath = "data source ="&server.mappath(filename)
set getSecuredmdbconnection = getConnection(Provider&DBPath& "; Jet OLEDB:データベースパスワード="&パスワード)end function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDBCConnection(filename)
Dim Driver、SourceType、DBPath
driver = "driver = {microsoft visual foxproドライバー};"
sourcetype = "sourceType = dbc;"
dbpath = "sourcedb ="&server.mappath(filename)
getDBCConnection = getConnection(driver&sourcetype&dbpath)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDbfConnection(ディレクトリ)
Dim Driver、SourceType、DBPath
driver = "driver = {microsoft visual foxproドライバー};"
sourcetype = "sourceType = dbf;"
dbpath = "sourcedb ="&server.mappath(ディレクトリ)
getDbfConnection = getConnection(driver&sourcetype&dbpath)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getExcelConnection(filename)
薄暗いドライバー、dbpath
driver = "driver = {microsoft excel driver(*.xls)};"
dbpath = "dbq ="&server.mappath(filename)
getExcelConnection = getConnection(driver& "readonly = 0;"&dbpath)end関数を設定します
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getTextConnection(ディレクトリ)
薄暗いドライバー、dbpath
driver = "driver = {microsoft text driver( *.txt; *.csv)};"
dbpath = "dbq ="&server.mappath(ディレクトリ)
getTextConnection = getConnection(driver&dbpath)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getSqlServerConnection(コンピューター、ユーザーID、パスワード、DB)
Dim Params、conn
GetSqlServerConnection = Nothingを設定します
params = "provider = sqloledb.1"
params = params& "; data source ="&computer
params = params& "; user id ="&userid
params = params& "; password ="&password
params = params& ";初期カタログ="&db
conn = server.createObject( "adodb.connection")を設定します
conn.open params
GetSqlServerConnection = connを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getmdbrecordset(filename、source)
getmdbrecordset = getmdbrs(filename、source、2、 ""を設定します)
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getMdbstaticRecordset(filename、source)
getmdbstaticRecordset = getMdbrs(filename、source、3、 ""を設定します)
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getsecuredMdbrecordset(filename、source、password)
set getSecureDmdbrecordset = getMdbrs(filename、source、2、password)end function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getSecuredMDBStaticRecordSet(Filename、Source、Password)
set getSecuredMdbstaticRecordset = getMdbrs(filename、source、3、password)end function
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDBFrecordset(ディレクトリ、SQL)
getDbFrecordset = getotherrs( "dbf"、directory、sql、2)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDbfstaticRecordset(ディレクトリ、SQL)
getDbfstaticRecordset = getotherrs( "dbf"、directory、sql、3)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDbCrecordset(filename、sql)
set getDbcrecordset = getotherrs( "dbc"、filename、sql、2)
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getDBCStaticRecordSet(filename、sql)
getDBCStaticRecordset = getotherrs( "dbc"、filename、sql、3)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getExcelRecordset(filename、sql)
getExcelRecordset = getotherrs( "excel"、filename、sql、2)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getExcelStaticRecordset(filename、sql)
getExcelStaticRecordset = getotherrs( "excel"、filename、sql、3)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getTexTrecordset(ディレクトリ、SQL)
getTexTreCordset = getotherrs( "text"、directory、sql、2)を設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getTextStaticRecordSet(ディレクトリ、SQL)
set getTextStaticRecordset = getotherrs( "text"、directory、sql、3)
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getSqlServerRecordset(conn、source)
薄暗いrs
rs = server.createObject( "adodb.recordset")を設定します
Rs.Open Source、Conn、2、2
GetSqlServerRecordset = rsを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getSqlServerStaticRecordset(conn、source)
薄暗いrs
rs = server.createObject( "adodb.recordset")を設定します
Rs.Open Source、Conn、3、2
GetSQlServerStaticRecordset = rsを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getConnection(param)
dim conn
エラーの再開時に次に再開します
GetConnection = Nothingを設定します
conn = server.createObject( "adodb.connection")を設定します
err.number <> 0の場合、機能を終了します
conn.open param
err.number <> 0の場合、機能を終了します
getConnection = connを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getMdbrs(ファイル名、ソース、カーソル、パスワード)
Dim Conn、Rs
エラーの再開時に次に再開します
getmdbrsを設定=何もありません
Len(パスワード)= 0の場合
set conn = getmdbconnection(filename)
それ以外
set conn = getsecuredmdbconnection(filename、password)
ifを終了します
connが何もない場合は、出口関数です
rs = server.createObject( "adodb.recordset")を設定します
err.number <> 0の場合、機能を終了します
Rs.Open Source、Conn、Cursor、2
err.number <> 0の場合、機能を終了します
getmdbrs = rsを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getotherrs(データ型、パス、sql、カーソル)
Dim Conn、Rs
エラーの再開時に次に再開します
getotherrs = Nothingを設定します
ケースデータタイプを選択します
ケース「DBF」
set conn = getdbfconnection(path)
ケース「DBC」
set conn = getDBCCONNECTION(PATH)
ケース「Excel」
set conn = getExcelConnection(パス)
ケース「テキスト」
set conn = getTextConnection(PATH)
[選択]を終了します
connが何もない場合は、出口関数です
rs = server.createObject( "adodb.recordset")を設定します
err.number <> 0の場合、機能を終了します
rs.open sql、conn、cursor、2
err.number <> 0の場合、機能を終了します
getotherrs = rsを設定します
エンド関数
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
関数getSqlServerrs(コンピューター、ユーザーID、パスワード、DB、ソース、カーソル)
Dim Conn、Rs
エラーの再開時に次に再開します
GetSqlServerrs = Nothingを設定します
set conn = getsqlserverconnection(コンピューター、ユーザーID、パスワード、db)
connが何もない場合は、出口関数です
rs = server.createObject( "adodb.recordset")を設定します
err.number <> 0の場合、機能を終了します
Rs.Open Source、Conn、Cursor、2
err.number <> 0の場合、機能を終了します
set getSqlServerrs = rs
エンド関数
%>
上記は、ユニバーサルデータベース接続プログラムの詳細な紹介です。その他のコンテンツについては、間違った新しいテクノロジーチャネルに注意を払い続けてください!