作者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
推 fumizuki:用ViewState去記錄查過的資料 08/04 22:26
→ amigoe:不知道是否可以提供一個範例 因為我沒用過這個方式 感謝 08/04 23:01