M
mhnazly
i'm trying to read data from SQL Server database using
data reader and assigned it to a label in my asp.net web
application. but when the button is clicked, nothing
appears. please help, thanks.
Private Sub btnTesting_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnTesting.Click
Dim cn As New SqlClient.SqlConnection
Dim cm As New SqlClient.SqlCommand
Dim dr As SqlClient.SqlDataReader
cn.ConnectionString = _
"data source=MHNAZLY;initial catalog=MEDICAL;"
Try
cn.Open()
Try
cm.Connection = cn
cm.CommandText = "SELECT StaffID,
StaffName, Designation, Contact_no, Email FROM
Admin_Staff WHERE(StaffID='1001104214')"
dr = cm.ExecuteReader()
Try
While dr.Read()
'lblDoctorID.Text = dr.Item
("StaffID").ToString()
lblDoctorID.Text = dr.GetString(1)
End While
Finally
dr.Close()
End Try
Finally
cn.Close()
End Try
Catch ex As Exception
End Try
End Sub
..
data reader and assigned it to a label in my asp.net web
application. but when the button is clicked, nothing
appears. please help, thanks.
Private Sub btnTesting_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnTesting.Click
Dim cn As New SqlClient.SqlConnection
Dim cm As New SqlClient.SqlCommand
Dim dr As SqlClient.SqlDataReader
cn.ConnectionString = _
"data source=MHNAZLY;initial catalog=MEDICAL;"
Try
cn.Open()
Try
cm.Connection = cn
cm.CommandText = "SELECT StaffID,
StaffName, Designation, Contact_no, Email FROM
Admin_Staff WHERE(StaffID='1001104214')"
dr = cm.ExecuteReader()
Try
While dr.Read()
'lblDoctorID.Text = dr.Item
("StaffID").ToString()
lblDoctorID.Text = dr.GetString(1)
End While
Finally
dr.Close()
End Try
Finally
cn.Close()
End Try
Catch ex As Exception
End Try
End Sub
..