【vfp开源代码栏目提醒】:网学会员--在 vfp开源代码编辑为广大网友搜集整理了:自动更新参数化odbc.prg绩等信息,祝愿广大网友取得需要的信息,参考学习。
CLEAR
LOCAL cConnString,oCursor as CursorAdapter,aErrors[1]
cConnString="driver=SQL Server;server=ccb-zhj;database=Northwind;uid=sa;pwd=;trusted_connection=no"
oCursor=NEWOBJECT("CursorAdapter")
WITH oCursor
.AllowDelete=.T.
.AllowInsert=.T.
.AllowUpdate=.T.
.Alias="curCustomer"
.BufferModeOverride=5
.DataSource=SQLSTRINGCONNECT(cConnString)
.DataSourceType="ODBC"
*!* 请注意下面的参数化
查询语句
.SelectCmd="SELECT CustomerID,CompanyName,ContactName FROM Customers WHERE Country=?lcVar"
.KeyFieldList="CustomerID"
.Tables="Customers"
.UpdatableFieldList="CustomerID,CompanyName,ContactName"
.UpdateNamelist="CustomerID Customers.CustomerID,"+;
"CompanyName Customers.CompanyName,ContactName Customers.ContactName"
.SendUpdates=.T.
.ConflictCheckType=3
ENDWITH
lcVar=INPUTBOX("请输入国家名称:","提示") &&输入参数变量值
IF oCursor.CursorFill()
BROWSE
IF TABLEUPDATE(.T.)=.F.
=MESSAGEBOX("更新失败!",0+48,"提示")
ENDIF
ELSE
AERROR(aErrors)
=MESSAGEBOX(aErrors[2])
ENDIF