ネットで情報を探して見つけたのですが、デバッグ中にいくつか問題があったので修正したところ、まだ問題はありますが、普通に使えます。データ型の問題と SQL Server とアクセスの違いについては考慮されていませんでした。今後時間があれば改善します。誰かがそれを改善したら、コピーを送ってください。
次のようにコードをコピーします:<%
class SQLString
'************************************
'変数の定義
' *************************************
'sTableName ---- テーブル
名'iSQLType --- - SQL ステートメントの種類: 0-追加、1-更新、2-削除、3-クエリのWhere
---- 条件のOrder
---- ソート
メソッドのSQL ---- 値
Private sTableName,iSQLType,sWhere,sOrder 、sSQL
'************************************
'クラスの初期化/終了
'***********************************
Private Sub Class_Initialize()
sTableName=
iSQLType =0
sWhere=
sOrder=
sSQL=
End Sub
Private Sub Class_Terminate()
End Sub
'******************************** ** **
'Attribute
'***********************************
'テーブル名の
属性 Public を設定
Property LetTableName(value)
sTableName=value
End Property
'条件を設定します
Public Property Let Where(value)
sWhere=value
End Property
'並べ替え方法を設定します
Public Property Let Order(value)
sOrder=value
End Property
'クエリ ステートメントの種類を設定します
Public property Let SQLType(value)
iSQLType=value
select case iSQLType
case 0
sSQL=insert into {&*#}0 ( {& *#}1) 値 ({&*#}2)
ケース 1
sSQL=update {&*#}0 セット {&*#}1={&*#}2
ケース 2
sSQL=delete from {&*#}0
case 3
sSQL=select {&*#}1 from {&*#}0
end select
End プロパティ
'******************** ****************
'関数
'****************************** * ****
'フィールドの追加 (フィールド名、フィールド値)
Public Sub AddField(sFieldName,sValue)
select case iSQLType
case 0
sSQL=replace(sSQL,{&*#}1,sFieldName & ,{&*#}1 )
sSQL=replace(sSQL,{&*#}2, & sValue & ,{&*#}2)
ケース 1
sSQL=replace(sSQL,{&*#}1,sFieldName)
sSQL=replace(sSQL,{&* #}2, & sValue & ,{&*#}1={&*#}2)
ケース 3
sSQL=replace(sSQL,{&*#}1,sFieldName & ,{&*#}1)
End Select
End Sub
'文字列値を返す変更された関数
' Return SQL ステートメント
Public Function ReturnSQL()
sSQL=replace(sSQL , {&*#}0,sTableName)
select case iSQLType
case 0
sSQL=replace(sSQL,,{&*#}1,)
sSQL=replace(sSQL,,{&*#}2,)
ケース 1
sSQL=replace(sSQL,,{&*#}1={&*#}2,)
ケース 3
sSQL=replace(sSQL,,{& *#}1,)
endif sWhere<> かつ iSQLType<>0 then
sSQL=sSQL & where & sWhere
end を
選択
if sOrder<> and iSQLType<>0 then
sSQL=sSQL & order by & sOrder
end if
ReturnSQL=sSQL
End Function
'Return SQL ステートメント
Public Function ReturnSQL1()
sSQL=replace(sSQL,{&*#}0,sTableName)
select case iSQLType
case 0
sSQL=replace(sSQL, ,{&*#}1,)
sSQL=replace(sSQL,,{&*#}2,)
ケース 1
sSQL=replace(sSQL,,{&*#}1={&*#}2,)
case 3
sSQL=replace(sSQL,,{&*#}1,)
end
sWhere<> および iSQLType<>0 の場合に
選択しますthen
sSQL=sSQL & where & sWhere
end if
sOrder<> かつ iSQLType<>0 then
sSQL=sSQL & order by & sOrder
end if
ReturnSQL=sSQL
End Function
'Clear ステートメント
Public Sub Clear()
sTableName=
iSQLType=0
sWhere=
sOrder=
sSQL=
End Sub
End class
%>
呼び出し例:
<%
set a =new SQLString 'クラス オブジェクトの作成
a.TableName= message 'テーブル名の設定to message
'a.where= issend =9
'a.order= issend desc
a.SQLType=0 'レコードを追加するクエリ タイプを設定します
a.AddField incept, '2'
a.AddField 送信者 、 '%3%'
a.AddField タイトル 、 #&now&#
a.AddField 送信者 、 5
a.AddField コンテンツ 、 6
a.AddField sendtime 、 7
a.AddField フラグ、 8
a.AddField issend 、 9
応答。 a.ReturnSQl
set a=nothing
%>
<%
set a =new SQLString
を書き込みます。'クラス オブジェクトを作成します
a.TableName= message 'テーブル名を設定します message
'a.where= issend =9
'a.order= issend desc
a.SQLType=0 'レコードを追加するクエリ タイプを設定します
a.AddField incept, ' 2'
a.AddField 送信者 , '%3%'
a.AddField タイトル , #&now&#
a.AddField 送信者 , 5
a.AddField コンテンツ , 6
a.AddField sendtime , 7
a.AddField flag, 8
a.AddField issend , 9
Response.Write a.ReturnSQl
set a=nothing
%>
<%
set a =new SQLString 'クラスオブジェクトの作成
a.TableName= message 'テーブル名を設定メッセージの場合
'a.where= issend =9
'a.order= issend desc
a.SQLType=0 'レコードを追加するクエリの種類を設定します
a.AddField incept, '2'
a.AddField sender , '%3%'
a.AddField title , #&now&#
a.AddField sender , 5
a.AddField content , 6
a.AddField sendtime 、7
a.AddField フラグ、8
a.AddField 送信、9
Response.Write a.ReturnSQl
セットa=何もなし
%>