hi,
I'm trying to fetch and display records in MDI toolbar. The step are as follows:
1. Enter a number in textbox in MDI toolbar.
2. Upon keypress, display records in MDI toolbar's textbox and labels
I f tried many times but failed. Plz help me, I'm newbie in vb.net n correct if I'm wrong.
Below is the code.
Looking forward for prompt reply.
Rgds,
jpdbay
I'm trying to fetch and display records in MDI toolbar. The step are as follows:
1. Enter a number in textbox in MDI toolbar.
2. Upon keypress, display records in MDI toolbar's textbox and labels
I f tried many times but failed. Plz help me, I'm newbie in vb.net n correct if I'm wrong.
Below is the code.
VB.NET:
Private Sub txtMRN_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMRN.KeyPress
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim drSQL As SqlDataReader
Dim strSQL As String
Try
' Build Select statement to query product information from the products table
strSQL = "SELECT mrn FROM tbl_patient_registration WHERE mrn=" & Val(Trim(txtMRN.Text))
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
' Populate form with the data
txtMRN.Text = drSQL.Item("mrn").ToString
lblName.Text = drSQL.Item("p_name").ToString()
lblSex.Text = drSQL.Item("p_sex").ToString()
End If
' Close and Clean up objects
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
Catch e1 As SqlException
MsgBox(e1.Message, MsgBoxStyle.Critical, "SQL Error")
Catch e2 As Exception
MsgBox(e2.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Looking forward for prompt reply.
Rgds,
jpdbay