步骤:
1、建立连接,或者连接句柄
如连接服务器为aa,用户名为bb,密码为cc,数据库为dd
nhandle=sqlstringconnect("driver=sql server;server=aa;uid=bb;pwd=cc;database=dd")
if nhandle>0
messagebox("数据库连接成功!",0,"提示")
else
messagebox("数据库连接成功!",0,"提示")
endif
2、如何向服务器取数据
如向服务器表employees查询性别为男的人员
在第一步建立和服务器数据库的连接,并取得连接句柄nhandle后
sqlexec(nhandle,"select * from employees where sex='男'","employees")
select employees
brow
也可以调用系统上的存储过程来取得数据.
如在服务器建立存储过程
create proc getmanofworkes
as
select * from employees where sex='男'
go
然后在vfp里调用
sqlexec(nhandle,"exec getmanofworkes",employees)
select employees
brow
当然也可以想存储过程传递参数查询
仍然以刚才的例子,查询不同性别的员工
在服务器上建立create proc getemployees
@sex char(2)='男'
as
select * from employees where sex=@sex
go
vfp里调用
查询男员工
csex='男'
sqlexec(nhandle,"exec getemployees ?sex",'employees')
select employees
brow
查询女员工
csex='女'
sqlexec(nhandle,"exec getemployees ?sex",'employees')
select employees
brow
设置本地表可更新服务器表
sqlexec(jb,"select id,bh,hyzhm,fzdw,rghsj,ghzrsj,xm,xb,gs_bm from rsda where lcbj=0 order by gbbh","gh")
***设置gh可更新rsda表
sele gh
cursorsetprop("tables","rsda","gh") &&设置临时表的更新目标表
cursorsetprop("keyfieldlist",'id',"gh") &&设置临时表的关键字
cursorsetprop("updatablefieldlist","id,fzdw,rghsj,ghzrsj,hyzhm","gh")&&设置临时表的更新字段
cursorsetprop("updatenamelist","id rsda.id,hyzhm rsda.hyzhm,rghsj rsda.rghsj,ghzrsj rsda.ghzrsj,fzdw rsda.fzdw","gh") &&&用gh中的相应字段更新rsda表
cursorsetprop("sendupdates",.t.,"gh")&&设置为可更新
cursorsetprop("wheretype",2)
cursorsetprop("buffering",5)&&设置表缓冲
【vfp如何使用spt】相关文章:
2018湖南省农村信用社联合社招聘科技专业人才拟聘公告03-23
at(the)least和not(in)the least用法区别 相似词语辨析(17)03-23
普通中学生入团志愿书500字通用范文03-23
计算机应用技术英语简历范文大全03-23
考试大:会计-支票英语用语03-23
常用职位英文译名(一)03-23
内蒙古党委组织部、人事厅拟录用公务员公告03-23
花落今秋,开何处?_650字03-23
2013年招商银行广东省深圳分行招聘应用系统参数规划与设计岗招聘启事03-23
