Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy anybody able to look at my system ? booking system

    booking system that won't save booking entry on a webform to a database ? been having trouble for about a week now and been posting here getting help from alot of people and just cant seem to get anywhere with the system, its a simple thing that im finding very hard, send me your email or private mail me if you think you can help and i will send you the system.

    below is the code which isnt working its been floating around asp.net for a few days now with no luck on how to fix it. it has no errors showing up at all but still wont do its job. I have until tonight to get it sorted for a university presentation.
    ===================================================

    Code:
    Imports System.Data.SqlClient
    
    Partial Class Bookings
        Inherits System.Web.UI.Page
    
        Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    
            Dim myconn As SqlConnection
    
    
    
            Dim sqlstring As String = ""
    
            Dim [ActivityName] As String = ddlActivityName.SelectedValue.ToString
            Dim [DateofBooking] As String = "txtDateofBooking.Text"
            Dim [TimeofBooking] As String = "txtTimeofBooking.Text"
    
            myconn = New SqlConnection("Provider=SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True")
    
            myconn.Open()
            sqlstring = "INSERT INTO Bookings (Activity Name, Time of Booking, Date of Booking)Values('" + [ActivityName] + "', '" + [DateofBooking] + "', '" + [TimeofBooking] + "') " '
    
            Dim command As New SqlCommand(sqlstring, myconn)
            command.Connection.Open()
            command.ExecuteNonQuery()
            myconn.Close()
    
    
        End Sub
    
    
    End Class
    [/CODE]

  • #2
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Small website straight forward just need someone to look over one page thanks :)

    I just need someone to look at it, no errors and its a very small website and everything is straightforward , it will take a professional or someone who is used to asp.net a couple of minutes to sort this , please could someone have a look everything looks fine just the code is doing nothing. I have a deadline for this website for tomorrow and it just needs this small push to get it finished. thanks to anybody who takes an interest in my post.

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,718
    Thanks
    41
    Thanked 191 Times in 190 Posts
    first thing you need to do is set a break point and make sure your three strings actually have a value

    Also I did this (I didn't know if you're brackets would cause an issue)
    Code:
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    
            Dim query As String = String.Format("insert into tbl_People values ('{0}','{1}','{2}','{3}','{4}')", TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text)
            Dim [parm1] As String = "_A_demo"
            Dim [parm2] As String = "_A_demoL"
            Dim [parm3] As String = "123654987"
            Dim parm4 As String = "132 fake"
            Dim parm5 As String = "11111"
            Dim _Query As String = "insert into tbl_People values ('" + [parm1] + "','" + [parm2] + "','" + [parm3] + "','" + parm4 + "','" + parm5 + "')"
    
            Dim conn As New SqlConnection(cnstr)
            Using conn
                conn.Open()
                Dim cmd As New SqlCommand(_Query, conn)
                cmd.CommandType = CommandType.Text
                Using cmd
                    cmd.ExecuteNonQuery()
                End Using
                conn.Close()
            End Using
            TextBox1.Text = TextBox2.Text = TextBox3.Text = TextBox4.Text = TextBox5.Text = ""
        End Sub
    now I tried various combinations of &, +, []'s on all, []'s on some, as well as dynamic pulling from a text box...
    I also tried this
    Code:
                Using cmd
                    'Dim dr As SqlDataReader = cmd.ExecuteReader
                    'Dim tmptbl As New DataTable
                    'tmptbl.Load(dr)
                    'TextBox1.Text = tmptbl.Rows.Count
                    cmd.ExecuteNonQuery()
                End Using
    with the code uncommented and removing the cmd.executenonquery with a select statement- to verify my connection was sound. I would try that as well.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •