以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]字串符分离的问题?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=29522)

--  作者:红颜
--  发布时间:2013/3/8 11:17:00
--  [求助]字串符分离的问题?

Dim lst As WinForm.ListBox = e.form.Controls("ListBox1")

Dim val As String = e.form.Controls("ComboBox1").Value.split(",")(0)
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT BH,BRXM,MC From {SFMX} Where BH = " & val & ""
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.datarows
    lst.items.Add(dr("BH") & "," & dr("BRXM") & "," & dr("MC"))
Next

 

问题在代码红色部分。

如题:

20130308-001,答复,大生化,直接分离出前边编号(20130308-001)


--  作者:红颜
--  发布时间:2013/3/8 11:44:00
--  
以下是引用muhua在2013-3-8 11:21:00的发言:

Dim Tel As String = "20130308-001,答复,大生化"
Dim Parts() As String = Tel.Split(",")
Output.Show(Parts(0))

 

 

参考资料:http://www.foxtable.com/help/topics/1421.htm

 

问题在这:

 

cmd.CommandText = "SELECT DISTINCT BH,BRXM,MC From {SFMX} Where BH = " & val & ""