| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 622 人关注过本帖
标题:关于SQL2000+VFP问题,以下代码请各大虾帮忙查一下问题出在哪里,不胜感激
取消只看楼主 加入收藏
zhangzhixian
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
结帖率:0
收藏
已结贴  问题点数:10 回复次数:0 
关于SQL2000+VFP问题,以下代码请各大虾帮忙查一下问题出在哪里,不胜感激
任务:
读取SQL2000中两个表tbljlcs和tbljlcs-1,其中tbljlcs为主表,tbljlcs-1为付表,索引关键字为jydh,希望运行后,从SQL2000获取的表能关联起来,以便进行查询、编辑等作业。
目前运行以下代码
1.表格内数据不能显示
2.SQL2000中两个表都有数据,但是查询后关联的记录为0
表单init:
nHandle=GetConnHandle()
IF nHandle>0
    nResult=SQLEXEC(nHandle,"SELECT * FROM tbljlcs","curjlcs")
    IF nResult<=0
        =MESSAGEBOX("读取数据出错!",0+48,"提示")
        This.opgFind.Enabled=.F.
        This.cmdStart.Enabled=.F.
 
    ENDIF
ENDIF
This.SetGrid()    &&设置grdFind表格的属性
Thisform.Refresh
表单setgrid:
IF USED("curjlcs_1")
    SET DELETED ON
    *!* 下面的代码用于设置临时表为可更新表
    cCursor="curjlcs_1"
    cRemoteTable="tbljlcs_1"
    cKeyFieldList="jydh"
    cUpdatableFieldList="jydh,xh,jcxm,bzcc,sccc,dw,pd,pd1"
    cUpdateNameList=;
        "jydh tbljlcs_1.jydh,"+;
        "xh tbljlcs_1.xh,"+;
        "jcxm tbljlcs_1.jcxm,"+;
        "bzcc tbljlcs_1.bzcc,"+;
        "sccc tbljlcs_1.sccc,"+;
        "dw tbljlcs_1.dw,"+;
        "pd tbljlcs_1.pd,"+;
        "pd1 tbljlcs_1.pd1"
    =SetCursorToUpdate(cCursor,cRemoteTable,cKeyFieldList,cUpdatableFieldList,cUpdateNameList)
    *!* 设置表格的数据源
    This.grdFind.RecordSourceType=1
    This.grdFind.RecordSource="curjlcs_1"
ELSE
    This.grdFind.RecordSource=""
ENDIF

WITH This.grdFind
    .AllowCellSelection=.F.
    .ColumnCount=6
    .LockColumns=2
    .DeleteMark=.F.
    .RecordMark=.F.
    .GridLineColor=RGB(192,192,192)
    .Column1.Header1.Caption="项号"
    .Column1.Width=23
    .Column1.BackColor=RGB(249,249,244)
    .Column2.Header1.Caption="检测项目"
    .Column2.Width=178
    .Column2.BackColor=RGB(249,249,244)
    .Column3.Header1.Caption="标准尺寸"
    .Column3.Width=91
    .Column4.Header1.Caption="实测尺寸"
    .Column4.Width=344
    .Column5.Header1.Caption="单位"
    .Column5.Width=36
    .Column6.Header1.Caption="判定"
    .Column6.AddObject("Check1","Checkbox")
    .Column6.CurrentControl="Check1"
    .Column6.Check1.Caption=""
    .Column6.Check1.Visible=.T.
    .Column6.Sparse=.F.
    .Column6.Alignment=2
    IF USED("curjlcs_1")
        .Column1.ControlSource="curjlcs_1.xh"
        .Column2.ControlSource="curjlcs_1.jcxm"
        .Column3.ControlSource="curjlcs_1.bzcc"
        .Column4.ControlSource="curjlcs_1.sccc"
        .Column5.ControlSource="curjlcs_1.dw"
        .Column6.ControlSource="curjlcs_1.pd"
     ENDIF
ENDWITH  
表单unload
IF USED("curjlcs_1")
    SELECT curjlcs_1
    cFldState=GETFLDSTATE(-1)
    IF "2"$cFldState OR "3"$cFldState OR "4"$cFldState
        IF MESSAGEBOX("记录已经被修改,是否保存?",4+32,"提示")=6
            IF TABLEUPDATE(.F.,.F.,"curjlcs_1")=.F.
                IF MESSAGEBOX("数据已经被其他用户更改,单击“是”将覆盖其他用户所做的修改,"+;
                    CHR(13)+"单击“否”将放弃当前所做的修改。",4+64,"提示")=6
                    IF TABLEUPDATE(.F.,.T.,"curjlcs_1")=.F.
                        =MESSAGEBOX("无法覆盖其他用户所做的修改,只能放弃修改!",0+64,"提示")
                        =TABLEREVERT(.F.,"curjlcs_1")
                    ENDIF
                ELSE
                    =TABLEREVERT(.F.,"curjlcs_1")
                ENDIF
            ENDIF
        ELSE
            =TABLEREVERT(.F.,"curjlcs_1")
        ENDIF
    ENDIF
ENDIF
RELEASE Thisform
查询按钮:
nHandle=GetConnHandle()                   &&获得连接句柄
IF nHandle>0
    IF SQLGETPROP(nHandle,"ConnectBusy")  &&检测连接是否忙碌
        =MESSAGEBOX("连接忙碌,请稍候再试!",0+48,"提示")
        RETURN
    ELSE
    cWhere="WHERE "+ALLTRIM(Thisform.Text1.Value)
        *!* 取得要执行的查询可以返回的记录总数
        nRecordNumber=0
        cSQLString='EXECUTE p_getrecordnumber "tbljlcs_1",'+'"curjlcs",'+;
        '"alltrim(tbljlcs_1.jydh)==ALLTRIM(curjlcs.jydh)","'+cWhere+'",?@nRecordNumber'
           *WAIT WINDOW cSQLString
        =SQLSETPROP(nHandle,"Asynchronous",.F.)   &&设置为同步连接
        IF SQLEXEC(_SCREEN.ConnectHandle,cSQLString)<=0  &&执行失败
            =MESSAGEBOX("获取记录数目失败!",0+48,"提示")
            RETURN
        ENDIF
        =ShowProgress(nRecordNumber)             &&显示工具栏中的进度条
        =SQLSETPROP(nHandle,"Asynchronous",.T.)  &&设置为异步连接
          _SCREEN.SQLString="SELECT * FROM tbljlcs_1,"+;
            "tbljlcs.jydh,"+;
            "tbljlcs.cpbh,"+;
            "tbljlcs.cpgg,"+;
            "FROM curjlcs_1 "+;
            "INNER JOIN curjlcs "+;
            "ON jlcs_1.jydh=tbljlcs.jydh "+;
            " ORDER BY tbljlcs_1.jydh,jlcs_1.xh"
*!*                _SCREEN.SQLString="SELECT * FROM tbljlcs_1,"+;
*!*                "tbljlcs.jydh,"+;
*!*                "tbljlcs.cpbh,"+;
*!*                "tbljlcs.cpgg,"+;
*!*                "FROM curjlcs_1 "+;
*!*                "INNER JOIN curjlcs "+;
*!*                "ON jlcs_1.jydh=tbljlcs.jydh "+;
*!*                " ORDER BY tbljlcs_1.jydh,jlcs_1.xh"
        _SCREEN.ExecMethodAfterSQL="frmEdit.SetGrid()"+CHR(13)+;
        "frmEdit.grdFind.Setfocus"      &&设置在读取数据完成后要执行的程序语句
        _SCREEN.CursorName="curjlcs_1"
        _SCREEN.TotleFetchRec=0             &&清空总记录数
        =CURSORSETPROP("FetchAsNeeded",.T.,0)  &&设置根据需要下载记录
        *!* 下面的语句指定每次读取100条记录,如果希望进度条显示的更准确可以设置每次读取1条,
        *!* 但是读取速度会明显下降
        =CURSORSETPROP("FetchSize",100,0)   
        IF USED("curjlcs_1")   &&关闭表,重新读取
            USE IN curjlcs_1
            Thisform.SetGrid()
        ENDIF
        =SQLEXEC(nHandle,_SCREEN.SQLString,"curjlcs_1")
        
        
    ENDIF
ENDIF
搜索更多相关主题的帖子: 不胜感激 关键字 
2011-03-19 14:49
快速回复:关于SQL2000+VFP问题,以下代码请各大虾帮忙查一下问题出在哪里,不胜 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032990 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved