主题:让我头痛的 四个 问题
homayzh
[专家分:7040] 发布于 2008-06-20 13:02:00
为了不占用本论坛空间,我把问题发在一起,希望各位老师 不吝赐教
CREATE DATABASE mydata &&
CREATE CONNECTION homayzh DATASOURCE station
CREATE SQL VIEW myview CONNECTION homayzh SHARE as select * from smmuser
DBSETPROP("myview", "View", "SendUpdates", .T.) &&远程视图可更新
USE myview
browse
一、怎么删除远程表记录,
二、用程序移动EDIT的内容,因为我要向EDIT编辑框里不停发数据,当EDIT满了自动向下翻,
三、sql表类型,MyISAM 和 InnDB 是什么意思?
四、我进了SQL建立了一个数据表,(不是用的VFP),用上面的方法建立了视图,虽然可以添加记录,一但数据添加上就不可更改了!!我怀疑和MyISAM 和 InnDB 有关,提示是
<没有为要更新的表"myessage"指定关键列,请使用临时表的keyfieldlist属性。>
回复列表 (共13个回复)
沙发
homayzh [专家分:7040] 发布于 2008-06-20 13:20:00
二、用程序移动EDIT的内容,因为我要向EDIT编辑框里不停发数据,当EDIT满了自动向下翻,
问题已解决
用
if len(allt(thisform.edit1.value ))> 1000
thisform.edit1.selstatr = len(allt(thisform.edit1.value))-100
endif
板凳
homayzh [专家分:7040] 发布于 2008-06-22 11:31:00
没有人愿意帮帮我吗?
3 楼
LuckyLine [专家分:1940] 发布于 2008-06-22 20:45:00
要更新远程视图,需要设置五个属性:Tables,KeyFieldList,UpdatableList,UpdateNameList以及SendUptables。用CursorSetProp()函数。
4 楼
homayzh [专家分:7040] 发布于 2008-06-23 09:08:00
CREATE DATABASE mydata &&
CREATE CONNECTION homayzh DATASOURCE station
CREATE SQL VIEW myview CONNECTION homayzh SHARE as select * from smmuser
DBSETPROP("myview", "View", "SendUpdates", .T.) &&远程视图可更新
再请教:比如,我用上面语句,建立了远程视图,这个表有3第记录
怎么删除后最一条记录?
5 楼
LuckyLine [专家分:1940] 发布于 2008-06-23 09:21:00
我是这样做的:
nhdl=sqlstringconnect("连接字串")
=sqlexec(nhdl,"select * from tblName","curName")&下载远程表为临时表
&然后远程数据更新设置五个属性
&对临时表curName做各种操作,包括删除之类,同本地表完全一样
&做删除操作应该保证KeyFieldList中设置的字段值具有唯一值,否则会删除一批记录
&最后用TableUpdate()函数向服务器发送更新
6 楼
yjr3032570 [专家分:3360] 发布于 2008-06-23 16:50:00
视图可更新有三种方法:
1、最简单的方法就是视图设计器中在更新条件中设置:SQL可更新;重置关键字。
2、用DBSETPROP()属性设置:
CREATE DATABASE mydata &&
CREATE CONNECTION homayzh DATASOURCE station
CREATE SQL VIEW myview CONNECTION homayzh SHARE as select * from smmuser
DBSETPROP("myview", "View", "SendUpdates", .T.) &&远程视图可更新
DBSetProp("myview.关键字","FIELD","keyfield",.T.)
use myview
brow
3、用CURSORSETPROP()属性设置:
CREATE DATABASE mydata &&
CREATE CONNECTION homayzh DATASOURCE station
CREATE SQL VIEW myview CONNECTION homayzh SHARE as select * from smmuser
use myview
CURSORSETPROP('SENDUPDATES',.T.)
CURSORSETPROP('KEYFIELDLIST','关键字')
brow
删除处理和vfp是一样的,只是不用pack
如果第三条要删除
go 3
dele
或
dele for 条件
就可以了!
最主要问题是这个关键字一定是唯一的,否则就会产生错误!
自增量是最简单的办法!
7 楼
homayzh [专家分:7040] 发布于 2008-07-01 12:28:00
请教3、5楼老师
怎么设置这五个属性呢??
8 楼
时光倒流 [专家分:660] 发布于 2008-07-01 14:31:00
这里有sql-vfp的详细的讲解(13个实例讲解),你可以看看
http://www.atongrj.cn/show.aspx?id=1868&cid=34
9 楼
LuckyLine [专家分:1940] 发布于 2008-07-01 20:16:00
先写一个函数:
* filename : SetCursorToUpdate.prg
LPARAMETERS cCursor,cRemoteTable,cKeyFieldList,cUpdatableFieldList,cUpdateNameList
***设置临时表为开放式行缓冲
=CURSORSETPROP("Buffering",3,cCursor)
***设置要更新的远程表名称
=CURSORSETPROP("Tables",cRemoteTable,cCursor)
***设置主键
=CURSORSETPROP("KeyFieldList",cKeyFieldList,cCursor)
***设置在临时表中需要跟踪变动的列
=CURSORSETPROP("UpdatableFieldList",cUpdatableFieldList,cCursor)
***设置远程表字段和临时表字段的对应关系
=CURSORSETPROP("UpdateNameList",cUpdateNameList,cCursor)
***设置临时表为可更新表
=CURSORSETPROP("SendUpdates",.t.,cCursor)
调用例子:
=SQLEXEC(nHandle,"select * from student","curStudent")
ThisForm.grdStudent.RecordSourceType= 1
ThisForm.grdStudent.RecordSource="curStudent"
cKeyFieldList="studentnumber"
cUpdadableFiledList="studentnumber,studentname,"+;
"studentpassword,sex,class,registerdate,profno,term"
cUpdateNameList="studentnumber student.studentnumber,"+;
"studentname student.studentname,"+;
"studentpassword student.studentpassword,"+;
"sex student.sex,"+;
"class student.class,"+;
"registerdate student.registerdate,"+;
"profno student.profno,"+;
"term student.term"
=SetCursorToUpdate("curStudent","student",cKeyFieldList,cUpdadableFiledList,cUpdateNameList)
其中student是SQL数据库表,curStudent则是它的临时表
10 楼
homayzh [专家分:7040] 发布于 2008-07-05 08:53:00
这个是列子吗?我试了几次,都不成功!!我远程表是 my_yyz
结构
=SQLEXEC(nHandle,"select * from student","curStudent")
ThisForm.grdStudent.RecordSourceType= 1
ThisForm.grdStudent.RecordSource="curStudent"
cKeyFieldList="studentnumber"
cUpdadableFiledList="studentnumber,studentname,"+;
"studentpassword,sex,class,registerdate,profno,term"
cUpdateNameList="studentnumber student.studentnumber,"+;
"studentname student.studentname,"+;
"studentpassword student.studentpassword,"+;
"sex student.sex,"+;
"class student.class,"+;
"registerdate student.registerdate,"+;
"profno student.profno,"+;
"term student.term"
=SetCursorToUpdate("curStudent","student",cKeyFieldList,cUpdadableFiledList,cUpdateNameList)
其中student是SQL数据库表,curStudent则是它的临时表
=CURSORSETPROP("Buffering",3,"proof_yyz")
=CURSORSETPROP("Tables","my_yyz","proof_yyz")
=CURSORSETPROP("KeyFieldList",'date','proof_yyz')
=CURSORSETPROP("UpdateNameList",'date,number,ch,ph,mk,yh,kf,mz,pz,jz,cl,getdata,yzh,bc','proof_yyz')
=CURSORSETPROP("UpdatableFieldList",'date,number,ch,ph,mk,yh,kf,mz,pz,jz,cl,getdata,yzh,bc','proof_yyz')
=CURSORSETPROP("SendUpdates",.t.,'proof_yyz')
我的表结构是
my_yyz
DATE 日期时间型 8
NUMBER 字符型 10
CH 字符型 10
PH 字符型 10
MK 字符型 60
YH 字符型 60
KF 数值型 8 2
MZ 数值型 8 2
PZ 数值型 8 2
JZ 数值型 8 2
CL 数值型 8 2
GETDATA 数值型 10 3
YZH 数值型 8 2
BC 字符型 10
请高人用此表给我写个例子,谢谢
我来回复