0
這是我的代碼過濾數據轉換成文本框/標籤如何顯示消息,如果沒有記錄,發現
Dim reader As MySqlDataReader
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim query As String
query = "SELECT * FROM member WHERE (memor = '" & memor.Text & "')"
sqlcom = New MySqlCommand(query, conn)
reader = sqlcom.ExecuteReader
While reader.Read()
Me.lblname.Text = reader("membname").ToString
Me.txtmembtype.Text = reader("membtype").ToString
Me.lblmembdate.Text = reader("membdate").ToString
End While
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
現在我想有提示,有沒有在我的MySQL數據庫中找到數據的消息框?任何想法?
'如果reader.HasRows().../ELSE MSGBOX /結束If' – Plutonix
你應該看看'Using'塊 - 你的連接,命令對象和讀者都應該[當你完成它們時處置](http://stackoverflow.com/a/29187199/1070452)。 – Plutonix