|
这个是我做的一个例子,你可以参考一下:
Dim dir
Dim tempPath
dir = Environment("TestDir")
tempPath = dir & "\function.vbs"
ExecuteFile tempPath
Call LoadEnvironment()
Call DBConnect()
Call selectRecord()
'Call insertRecord()
'Call updateRecord()
'Call deleteRecord()
Call DBClose()
Function selectRecord()
Dim tempValue
Dim strSQLString
strSQLString = "select * from t_bmn_staff_m"
Call ExecuteSql(strSQLString)
Do while not Res.eof
For i = 0 to 30
tempValue = "Line" & i & ":" & Res(i)
print(tempValue)
Next
Res.MoveNext
Loop
End Function
Function insertRecord()
Dim tempValue
Dim strSQLString
strSQLString = "insert into t_bmn_staff_m(STAFF_ID,INTERNAL_ID,SERVICE_STATUS,STAFF_NM_KANJI) values (?,?,?,?)"
Set tempValue = oCmd.CreateParameter("STAFF_ID", 129, 1, 10, "jinsen0001")
oCmd.Parameters.Append tempValue
Set tempValue = oCmd.CreateParameter("INTERNAL_ID", 131, 1, 10, "1000000000")
oCmd.Parameters.Append tempValue
Set tempValue = oCmd.CreateParameter("SERVICE_STATUS", 131, 1, 1, "1")
oCmd.Parameters.Append tempValue
Set tempValue = oCmd.CreateParameter("STAFF_NM_KANJI", 129, 1, 60, "テスト1です。")
oCmd.Parameters.Append tempValue
Call ExecuteSql(strSQLString)
End Function
Function updateRecord()
Dim tempValue
Dim strSQLString
strSQLString = "update t_bmn_staff_m t set t.staff_nm_kanji = ? where t.staff_id = ?"
Set tempValue = oCmd.CreateParameter("STAFF_NM_KANJI", 129, 1, 60, "テスト2です。")
oCmd.Parameters.Append tempValue
Set tempValue = oCmd.CreateParameter("STAFF_ID", 129, 1, 10, "jinsen0001")
oCmd.Parameters.Append tempValue
Call ExecuteSql(strSQLString)
End Function
Function deleteRecord()
Dim tempValue
Dim strSQLString
strSQLString = "delete t_bmn_staff_m t where t.staff_id = ?"
Set tempValue = oCmd.CreateParameter("STAFF_ID", 129, 1, 10, "jinsen0001")
oCmd.Parameters.Append tempValue
Call ExecuteSql(strSQLString)
End Function |
|