hi frnds,
i had got a problem,,,,,,,
when iam retriving the data from database uising an condition it will shows the data appropriately...
if the conditional value not in the database it will doesnot show any error.......
here iam acessing the data from database using serial number condition,,,,,
if the requested serial number not in the database it doesn't show any error.......
pls help me...
here my coding is given below.........

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles sino.TextChanged, sino.DataBinding
        Dim connstr As String
        connstr = ConfigurationManager.ConnectionStrings("guest1").ConnectionString()
        Dim conn As New SqlConnection(connstr)
        Dim dr As SqlDataReader
        Dim da As New SqlClient.SqlCommand("select date_of_arr,desig,dept,addr,room_no,no_beds,prior_booking,booked_by from guesthouse where booking_no='" + sino.Text + "' ", conn)
        conn.Open()
        dr = da.ExecuteReader()
        If dr.Read() Then
            dateofarrival.Text = dr(0).ToString().Substring(0).Remove(10)
            noofbeds.Text = dr(5).ToString
            roomno.Text = dr(4).ToString
            bookingname.Text = dr(6).ToString
            designation.Text = dr(1).ToString
            department.Text = dr(2).ToString
            address.Text = dr(3).ToString
            requestedby.Text = dr(7).ToString
        End If
        conn.Close()
    End Sub

iam using asp.net with vb.net,,
database=sqlserver-2005.....

Recommended Answers

All 2 Replies

hi frnds,
i had got a problem,,,,,,,
when iam retriving the data from database uising an condition it will shows the data appropriately...
if the conditional value not in the database it will doesnot show any error.......
here iam acessing the data from database using serial number condition,,,,,
if the requested serial number not in the database it doesn't show any error.......
pls help me...
here my coding is given below.........

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles sino.TextChanged, sino.DataBinding
Dim connstr As String
connstr = ConfigurationManager.ConnectionStrings("guest1").ConnectionString()
Dim conn As New SqlConnection(connstr)
Dim dr As SqlDataReader
Dim da As New SqlClient.SqlCommand("select date_of_arr,desig,dept,addr,room_no,no_beds,prior_booking,booked_by from guesthouse where booking_no='" + sino.Text + "' ", conn)
conn.Open()
dr = da.ExecuteReader()
If dr.Read() Then
dateofarrival.Text = dr(0).ToString().Substring(0).Remove(10)
noofbeds.Text = dr(5).ToString
roomno.Text = dr(4).ToString
bookingname.Text = dr(6).ToString
designation.Text = dr(1).ToString
department.Text = dr(2).ToString
address.Text = dr(3).ToString
requestedby.Text = dr(7).ToString
End If
conn.Close()
End Sub


iam using asp.net with vb.net,,
database=sqlserver-2005.....

Hi Kanuri

Pls. do the following
1) add a label in ur aspx page
2) modify the code ...

if dr.hasrows = false then
   label1.text = "No Record(s) found for the given criteria!!!"
else
If dr.Read() Then
            dateofarrival.Text = dr(0).ToString().Substring(0).Remove(10)
            noofbeds.Text = dr(5).ToString
            roomno.Text = dr(4).ToString
            bookingname.Text = dr(6).ToString
            designation.Text = dr(1).ToString
            department.Text = dr(2).ToString
            address.Text = dr(3).ToString
            requestedby.Text = dr(7).ToString
        End If
end if

Mark as solved if it helps you!!!

Hi

Here following example shows the example of message box.

MessageBox.Show("YourMessageHere",
"YourBoxTitleHere",
MessageBoxButtons.YourChoiceOfButtonsHere,
MessageBoxIcon.YourChoiceOfIconHere);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.