首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > VFP >

SQL查询值赋值有关问题

2012-08-11 
SQL查询值赋值问题SQL codelnHandleSQLConnect(lcODBCName,lcDBUser,lcDBPasswd)**定义变量SQLTEMPSELE

SQL查询值赋值问题

SQL code
lnHandle=SQLConnect(lcODBCName,lcDBUser,lcDBPasswd)**定义变量SQLTEMP="SELECT STUFF(STUFF((SELECT replace('"+alltrim(thisform.text11.value)+"','-','')),CHARINDEX(DQDM,(SELECT replace('"+alltrim(thisform.text11.value)+"','-','')),5),0,'-'),CHARINDEX(DQDM,(SELECT replace('"+alltrim(thisform.text11.value)+"','-','')),5)+LEN(DQDM)+1,0,'-') G_ZHH FROM gp_g_xxb WHERE replace('"+alltrim(thisform.text11.value)+"','-','')=G_ZHH"If lnHandle>0 &&连接成功    **查询数据)    SQLExec(lnHandle,SQLTEMP,"TEXT11TMP")    **赋查询值给数组    SELECT g_zhh FROM text11tmp INTO ARRAY text11t       **更新数据    If SQLExec(lnHandle,"insert into vk_bouns values (newid(),'(?TEXT11t(1))','"+alltrim(thisform.text12.value)+"','"+alltrim(thisform.text13.value)+"','"+alltrim(thisform.text14.value)+"','"+alltrim(thisform.text15.value)+"')")>0 &&运行成功        Thisform.commandgroup1.comOK.Click        Messagebox("新增成功",0,"提示")    Else &&失败     &&出错处理    EndifElse &&连接失败    Messagebox("连接SQL SERVER失败",16,"BUFFER")Endif


运行时不提示任何的错误,也无任何的更新结果,感觉是
SQL code
    **查询数据)    SQLExec(lnHandle,SQLTEMP,"TEXT11TMP")    **赋查询值给数组    SELECT g_zhh FROM text11tmp INTO ARRAY text11t 
 
SQL code
'(?TEXT11t(1))'

的问题,但是不知道问题出在那里,请大大看下如何解决

[解决办法]
SQL code
lnHandle=SQLConnect(lcODBCName,lcDBUser,lcDBPasswd)**定义变量SQLTEMP="SELECT STUFF(STUFF((SELECT replace('"+Alltrim(Thisform.text11.Value)+"','-','')),CHARINDEX(DQDM,(SELECT replace('"+Alltrim(Thisform.text11.Value)+"','-','')),5),0,'-'),CHARINDEX(DQDM,(SELECT replace('"+Alltrim(Thisform.text11.Value)+"','-','')),5)+LEN(DQDM)+1,0,'-') G_ZHH FROM gp_g_xxb WHERE replace('"+Alltrim(Thisform.text11.Value)+"','-','')=G_ZHH"If lnHandle>0 &&连接成功    **查询数据)    SQLExec(lnHandle,SQLTEMP,"TEXT11TMP")    **赋查询值给数组    Select g_zhh From text11tmp Into Array text11t    **更新数据    lcf2=Alltrim(Thisform.text12.Value)    lcf3=Alltrim(Thisform.text13.Value)    lcf4=Alltrim(Thisform.text14.Value)    lcf5=Alltrim(Thisform.text15.Value)    If SQLExec(lnHandle,"insert into vk_bouns values (newid(),?TEXT11t(1),?lcf2,?lcf3,?lcf4,?lcf5)")>0 &&运行成功        *If SQLExec(lnHandle,"insert into vk_bouns values (?newid(),?TEXT11t(1),?lcf2,?lcf3,?lcf4,?lcf5)")>0 &&运行成功        Thisform.commandgroup1.comOK.Click        Messagebox("新增成功",0,"提示")    Else &&失败        &&出错处理    EndifElse &&连接失败    Messagebox("连接SQL SERVER失败",16,"BUFFER")Endif 

热点排行