help 'e debug

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • menyki
    New Member
    • Feb 2007
    • 33

    #1

    help 'e debug

    I wrote the below code to input new data from name and address textbox of a form to microsoft access but there are alot of error. the name of the table in the access is Hotel and the the fields are HotelName and HotelAddress . Please can somebody help me and debug. i used vb.net


    Code:
    Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            Dim Objconn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ECBInvoicing.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
            Objconn.Open()
    
            ObjCmd = New SqlCommand("INSERT INTO hotel (HotelName, HotelAddress) VALUES (@HotelName, @HotelAddress)", Objconn)
    
    
            ObjCmd.Parameters.Add("@HotelName", Data.SqlDbType.VarChar).Value = txtHotelname.Text
            ObjCmd.Parameters.Add("@HotelAddress", Data.SqlDbType.VarChar).Value = txtHotelAddress.Text
    
    
            ObjCmd.ExecuteNonQuery()
    
    
            Objconn.Close()
    
        End Sub
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by menyki
    I wrote the below code to input new data from name and address textbox of a form to microsoft access but there are alot of error. the name of the table in the access is Hotel and the the fields are HotelName and HotelAddress . Please can somebody help me and debug. i used vb.net


    Code:
    Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            Dim Objconn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ECBInvoicing.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
            Objconn.Open()
    
            ObjCmd = New SqlCommand("INSERT INTO hotel (HotelName, HotelAddress) VALUES (@HotelName, @HotelAddress)", Objconn)
    
    
            ObjCmd.Parameters.Add("@HotelName", Data.SqlDbType.VarChar).Value = txtHotelname.Text
            ObjCmd.Parameters.Add("@HotelAddress", Data.SqlDbType.VarChar).Value = txtHotelAddress.Text
    
    
            ObjCmd.ExecuteNonQuery()
    
    
            Objconn.Close()
    
        End Sub
    Could you also post the errors you are receiving?

    Comment

    Working...