1.11M Members

checking available rooms using ASP.Net vb

 
0
 

Please can anyone cheack my work its not working with me !

Also if you have any simple Solution can I use, it will be better !

 Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim conString As String = "Data Source=BUSH;Initial Catalog=HOTEL;Integrated Security=True"
        Dim sqlCom As SqlCommand = New SqlCommand()
        Dim sqlCon As SqlConnection = New SqlConnection(conString)
        sqlCom.Connection = sqlCon
        sqlCom.CommandText = " SELECT distinct Type_of_Room, No_of_Days, Charge ,Date , Crand_Total FROM Room INNER JOIN BookingRoom ON Room.Room_ID <> BookingRoom.Room_ID INNER JOIN Booking ON BookingRoom.BookingID = Booking.BookingID WHERE [B]([/B]('" + TextBox4.Text + "' NOT BETWEEN booking.arrivedate AND booking.enddate) AND ('" + TextBox2.Text + "' NOT BETWEEN Bookingg.ArraieDate AND Booking.EndDate)[B])[/B] or Booking.BookingId = null"
        sqlCom.CommandType = CommandType.Text
        sqlCon.Open()
        sqlCom.ExecuteNonQuery()
        sqlCon.Close()
    End Sub

It showing me error in ExecuteNonQuery !! I don't Whay ! Also the insert data in my web not saving in database SQL server 2010 !

Please help me !!!

Regards ,
 
0
 

Have you tried your SQL query directly in the SQL management studio? It looks like you have quite a bit of spelling error in their. If that is how you spelled your tables and fields it is fine but I'd double check to make sure

 
0
 

Hi dear ,

Thanks for replaying me

Yes I connacet my Sql with VS but still not working !!

Also my ( login page ) not working !

Dim conString As String = "Data Source=BUSH;Initial Catalog=HOTEL;Integrated Security=True"
        Dim sqlcon As SqlConnection = New SqlConnection(conString)
        sqlcon.Open()
        Dim cmd As New SqlCommand("select * from Users where UserID =@UserID and Password=@Password", sqlcon)
        cmd.Parameters.AddWithValue("@UserID", txtUserID.Text)
        cmd.Parameters.AddWithValue("@Password", txtPWD.Text)
        Dim da As New SqlDataAdapter(cmd)
        Dim dt As New DataTable()
        da.Fill(dt)
        If dt.Rows.Count > 0 Then
            Response.Redirect("Room.aspx")
        Else
            ClientScript.RegisterStartupScript(Page.[GetType](), "validation", "<script language='javascript'>alert('Invalid UserName and Password')</script>")

        End If
 
0
 

Unfortunately, I am not able to help based on "its not working" along with snippets of your code.

Have you been able to connect from your code ever at all? If not, have you checked your connection string? Did you validate that you can actualy connect to SQL with the credentials supplied in your connection string. You have it set to Integrated Security. Is that compatible with your DB config?

In other words, first validate that you can infact connect from your code to SQL. When that is validated, try a simply SQL query. When that works, continue from there.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article