国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

ODBCAPI的VBSample

2019-11-18 17:28:29
字體:
供稿:網(wǎng)友
Example:

PRivateSubCommand1()
Dima_hEnvAsLong
Dima_hDBCAsLong
Dims_DistrictAsLong
Dimu_DistrictAsLong<p>DimQueryAsString
DimaTokenAsLong
DimRetAsInteger<p>Dims_parm1(256)AsByte
Dims_parm2AsInteger
Dims_parm3(256)AsByte
Dims_parm4AsInteger
DimaDTaxAsSingle
DimaNextOrderAsInteger
DimbNextOrderAsInteger
DimcbValue1AsLong
DimcbValue2AsLong
DimcbValue3AsLong
DimcbValue4AsLong
DimcbValue5AsLong
DimiAsInteger
’Variablesthatholdthelengthoftheparameters
cbValue1=SQL_NTS
cbValue2=0
cbValue3=SQL_NTS
cbValue4=0
cbValue5=0
’ConnecttoanAS/400
Ret=SQLAllocEnv(a_hEnv)’AllocatestheSQLenvironment
Ret=SQLAllocConnect(a_hEnv,a_hDBC)’Allocatesconnection
Ret=SQLConnect(a_hDBC,"BANANA",SQL_NTS,"SPEED",SQL_NTS,"SPEED2",SQL_NTS)
’Createapreparedstatementtoselectdata
Ret=SQLAllocStmt(a_hDBC,s_District)
Query="SelectDTAX,DNXTORfromQUSER.DSTRCTwhere(DWID=?andDID=?)"
Ret=SQLSetStmtOption(s_District,SQL_CONCURRENCY,SQL_CONCUR_READ_ONLY)
Ret=SQLPrepare(s_District,Query,SQL_NTS)


’Bindtheparametersfortheselectquery
Ret=SQLBindParameter(s_District,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,4,0,s_parm1(0),0,cbValue1)
Ret=SQLBindParameter(s_District,2,SQL_PARAM_INPUT,SQL_C_SSHORT,SQL_INTEGER,3,0,s_parm2,0,cbValue2)
Ret=SQLBindCol(s_District,1,SQL_C_FLOAT,aDTax,0,0&)
Ret=SQLBindCol(s_District,2,SQL_C_SSHORT,aNextOrder,0,0&)
’Createapreparedstatementtoupdatedata
Ret=SQLAllocStmt(a_hDBC,u_District)
Query="UpdateDSTRCTsetDNXTOR=?where(DWID=?andDID=?)"
Ret=SQLPrepare(u_District,Query,SQL_NTS)
’BindtheparametersfortheUpdatequery
Ret=SQLBindParameter(u_District,1,SQL_PARAM_INPUT,SQL_C_SSHORT,SQL_INTEGER,0,0,bNextOrder,0,cbValue5)
Ret=SQLBindParameter(u_District,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,4,0,s_parm3(0),0,cbValue3)
Ret=SQLBindParameter(u_District,3,SQL_PARAM_INPUT,SQL_C_SSHORT,SQL_INTEGER,3,0,s_parm4,0,cbValue4)
’YoushouldnotpasscharacterpointerstoDLL’ssoweconvertthemto
’bytearrays(actuallyfromUnicodecharaterstringstobytearrays)
CallStringToBytes("0001",256,s_parm1())’Warehouse
CallStringToBytes("0001",256,s_parm3())’Warehouse
’Thisloopwillincrementafieldintendifferentrows
Fori=1To10
’Settheparameters
s_parm2=i’District
s_parm4=i’District
’Executetheselectquery.
Ret=SQLExecute(s_District)
’Fetchresults.
Ret=SQLFetch(s_District)
Ret=SQLFreeStmt(s_District,SQL_CLOSE)
’Dosomeprocessingofthisrow...
’Thenincrementthefield
bNextOrder=aNextOrder 1
’Executetheupdate
Ret=SQLExecute(u_District)
Ret=SQLFreeStmt(u_District,SQL_CLOSE)
Next
’FreetheODBCresources
Ret=SQLFreeStmt(s_District,SQL_DROP)
Ret=SQLFreeStmt(u_District,SQL_DROP)
Ret=SQLDisconnect(a_hDBC)’Disconnectinganddeallocating.
Ret=SQLFreeConnect(a_hDBC)
Ret=SQLFreeEnv(a_hEnv)
EndSub

PrivateFunctionBytesToString(byte_array()AsByte)AsString
’convertbytearraytostring.
DimDataAsString,StrLenAsString
Data=StrConv(byte_array(),vbUnicode)
StrLen=InStr(Data,Chr(0))-1
BytesToString=Left(Data,StrLen)
EndFunction

PrivateSubStringToBytes(DataAsString,ByteLenAsInteger,return_buffer()AsByte)
’convertstringtobytearray.
DimStrLenAsInteger,CountAsInteger
ForCount=0ToLen(Data)-1
return_buffer(Count)=Asc(Mid(Data,Count 1,1))
NextCount
ForCount=Len(Data)ToByteLen
return_buffer(Count)=0
NextCount
EndSub->


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临颍县| 区。| 台东市| 巫溪县| 无极县| 鄱阳县| 济阳县| 宣恩县| 根河市| 罗平县| 济源市| 平安县| 清苑县| 谷城县| 苍溪县| 平山县| 邢台县| 阜平县| 五指山市| 德令哈市| 平定县| 习水县| 锦州市| 麻栗坡县| 醴陵市| 大竹县| 民勤县| 柳州市| 临西县| 突泉县| 永嘉县| 北票市| 德庆县| 昂仁县| 临泉县| 眉山市| 宜黄县| 临城县| 赫章县| 浦东新区| 清河县|