以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  用sql语句改写  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=55918)

--  作者:riyuan
--  发布时间:2014/8/26 10:53:00
--  用sql语句改写
Dim dr As DataRow
Dim zhanghao As String = e.Form.Controls("textbox1").Value
If zhanghao = Nothing Then
    MessageBox.Show("请输入您的登录账号!", "错误提示!",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel = True
Else
    DataTables("login").LoadFilter= "[登陆账号] = \'" & zhanghao & "\'"
    DataTables("login").Load
    dr = DataTables("login").Find("[登陆账号] = \'" & zhanghao & "\'")
    If dr Is Nothing Then
     Messagebox.show("登陆账号不对!","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
       e.Sender.Text=""
        e.Cancel = True
Else
    e.Form.Controls("textbox2").value=dr("登陆名")

                End If
End If

这段代码用sql语句怎么写

--  作者:Bin
--  发布时间:2014/8/26 10:55:00
--  
"select top 1 * from {login} where [登陆账号] = \'" & zhanghao & "\'"
--  作者:有点甜
--  发布时间:2014/8/26 10:55:00
--  

 你直接这样写即可 DataTables("login").SqlFind("[登陆账号] = \'" & zhanghao & "\'")

 

 http://www.foxtable.com/help/topics/2911.htm

 


--  作者:riyuan
--  发布时间:2014/8/26 11:16:00
--  
我没有在程序中加载外部表的,我要用sql语句来写。上面的例子都是加载了表的
--  作者:有点甜
--  发布时间:2014/8/26 11:17:00
--  

看2楼,用sqlcommand

 

http://www.foxtable.com/help/topics/0696.htm

 


--  作者:riyuan
--  发布时间:2014/8/26 11:32:00
--  
Dim hh As String
With e.Form
.Controls("textbox1").text=Tables("mm_Table2").current("户号")
.controls("textbox2").text= Tables("mm_Table2").current("姓名")
.Controls("textbox3").text=Tables("mm_Table2").Current("身份证号")

End With
hh=e.Form.Controls("textbox1").text
Dim cmd As New SQLCommand
cmd.C
Dim ld As String
cmd.CommandText = "Select * From {xlh} where 户号 =\'" & hh & "\'"
If cmd.ExecuteScalar> 0 Then
e.Form.Controls("textbox4").text =" xlh.合作医疗证号"
MessageBox.Show(ld)
Else
Return
End If

这段代码错在哪里, textbox4不级获取到xlh的医疗证号
mm_table2是另一个表的
医疗证号是xlh表中的


--  作者:有点甜
--  发布时间:2014/8/26 11:42:00
--  

cmd.CommandText = "Select top 1 * From {xlh} where 户号 =\'" & hh & "\'"
Dim dt As DataTable = cmd.ExecuteReader
If dt.DataRows.Count > 0 Then
    e.Form.Controls("textbox4").text = dt
.DataRows(0)("合作医疗证号")
Else
    Return
End If

[此贴子已经被作者于2014-8-26 11:42:38编辑过]