0

hi i want to show the message box using database conditions,,,,,
here my coding is given below.........

Protected Sub roomno_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles roomno.SelectedIndexChanged

Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("guest1").ConnectionString())
        Try
            conn.Open()
            Dim dr As System.Data.SqlClient.SqlDataReader
            Dim da As New SqlClient.SqlCommand("select room_no from guesthouse  WHERE room_no =  '" & roomno.SelectedItem.Text & "' and status <> 'C'", conn)
            dr = da.ExecuteReader
            While dr.Read()
                MsgBox("this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! ")
            End While
        Catch ex As Exception
            conn.Close()
        End Try

    End Sub

here the problem is not showing any message........
pls help me........
give me the correct coding........
pls help me urgent..........

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kanuri1
0

Hi

MsgBox function would not work on ASP.Net pages instead try using this to show alerts

Replace the following

MsgBox("this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! ")

with this and try

ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('" + "this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! " + "');</script>");
0

Hi

MsgBox function would not work on ASP.Net pages instead try using this to show alerts

Replace the following

MsgBox("this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! ")

with this and try

ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('" + "this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! " + "');</script>");

hi u have actually given code is not working ...........and it is not showing any error messages.........
why it is not working pls answer me .................

Edited by kanuri1: n/a

0

Hi,

Hope you had removed the ; at the end of the line before executing the code.

The code block should work. Since I dont have the working env of the database i was not able to execute the code and check. I just took the message withing the MSGBOX and replaced the same in the new syntax.

ClientScript.RegisterStartupScript would register a javascript and would show an alert message during execution.

Please try again in case of any issues please give the solution and the database will check the same and would let you know the correct fix.

Thanks
Vimal

0

Hi,

Hope you had removed the ; at the end of the line before executing the code.

The code block should work. Since I dont have the working env of the database i was not able to execute the code and check. I just took the message withing the MSGBOX and replaced the same in the new syntax.

ClientScript.RegisterStartupScript would register a javascript and would show an alert message during execution.

Please try again in case of any issues please give the solution and the database will check the same and would let you know the correct fix.

Thanks
Vimal

hi instead of your code i used the following code
but it shows error like "startIndex must be less than length of string."
why it was getting here my coding is as follows....
please help me urgent.........

Protected Sub roomno_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles roomno.SelectedIndexChanged

		conn.Open()
		Dim da As New SqlCommand("select room_no from guesthouse  WHERE room_no =  '" & roomno.SelectedItem.Text & "' and status <> 'C'", conn)
		Dim dr As System.Data.SqlClient.SqlDataReader
		dr = da.ExecuteReader
		If dr.Read() Then
			Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "<script language=JavaScript>alert('" & "this room is booked from " & dr(0).ToString().Substring(0).Remove(10) & " to " & dr(1).ToString().Substring(0).Remove(10) & ".so this room is available from  the date " & dr(1).ToString().Substring(0).Remove(10) & " onwards! " & "');</script>")
		End If
		conn.Close()
end sub

thnx
raghu

This topic has been dead for over six months. 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.