0

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.....

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by crishjeny
0

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!!!

Edited by reach_yousuf: n/a

0

Hi

Here following example shows the example of message box.

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.