作者amigoe (amigoe)
看板Visual_Basic
标题[.NET] 查询过得资料一直保留在画面上
时间Mon Aug 4 20:02:46 2008
请输入专案类型(网站专案或者应用程式专案):.NET
想请问高手们~
我想要查询商品是否有在资料库中
所以 每一次会先输入商品代码 如果有资料就会把资料显示在画面上
因为要查询多笔资料 我想把每一次查询到资料都保留在画面後
完成後一起印出来,请要怎麽让资料一直累积在画面上呢?
谢谢~~
Dim response As MsgBoxResult
Dim conn As OleDbConnection = New OleDbConnection(str)
Dim selectCmd As String
Dim selectName As String
selectName = InputBox("请输入编码", "查询")
selectCmd = "select * from codedata where sp_number =
'" & selectName & "'"
Dim adapter1 As OleDbDataAdapter = New OleDbDataAdapter(selectCmd, conn)
Dim cmd As OleDbCommand, myReader As OleDbDataReader
'conn = New OleDbConnection(connStr)
conn.Open()
cmd = New OleDbCommand(selectCmd, conn)
myReader = cmd.ExecuteReader()
If myReader.Read() Then
Do While myReader.Read()
txtshow.Text = "代码" & vbTab & myReader.Item("sp_number") & vbNewLine
txtshow.Text &= "商品" & vbTab & myReader.Item("name") & vbNewLine
txtshow.Text &= "编号" & vbTab & myReader.Item("sp_id") & vbNewLine
txtshow.Text &= "日期" & vbTab & myReader.Item("data") & vbNewLine
txtshow.Text &= "时间" & vbTab & myReader.Item("time")
Loop
Else
PlaySound(fWAV, 0, SND_FILENAME)
response = MsgBox("找不到!请重新确认!", MsgBoxStyle.Exclamation, "讯息")
End If
conn.Close()
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.126.248.77
1F:推 fumizuki:用ViewState去记录查过的资料 08/04 22:26
2F:→ amigoe:不知道是否可以提供一个范例 因为我没用过这个方式 感谢 08/04 23:01