SQL Database Connectivity Errors

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

    SQL Database Connectivity Errors

    here is an input code i wrote to input data from the user interface to database in access. error occured when i tried to run the problem. the error messages are as follow.
    1. ObjCmd is not declared
    2. SqlCommand is not defined.

    the code is as shown below (is written with vb.net). the name of the file in the access is chiscoTransport and the name of the table is seatReservation
    please help me debug the errors


    [CODE=vbnet]Private Sub submitButton_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles submitButton.Cl ick
    Dim Objconn As New SqlClient.SqlCo nnection("Data Source=.\SQLEXP RESS;AttachDbFi lename=|DataDir ectory|\chiscoT ransport.mdb;In tegrated Security=True;C onnect Timeout=30;User Instance=True")
    Objconn.Open()

    ObjCmd = New SqlCommand("INS ERT INTO seatReservation (vehicleID, pname, deptureT, trvllingft, pssngerAD, phoneNo, fare, time, exptdjd, date) VALUES (@vehicleID, @pname, @deptureT, @trvllingft, @pssngerAD, @phoneNo, @fare, @time, @exptdjd, @date)", Objconn)


    ObjCmd.Paramete rs.Add("@vehicl eID", Data.SqlDbType. VarChar).Value = vehicleIDComboB ox.Text
    ObjCmd.Paramete rs.Add("@pname" , Data.SqlDbType. Text).Value = pnameTextBox.Te xt
    ObjCmd.Paramete rs.Add("@deptur eT", Data.SqlDbType. Text).Value = deptureTComboBo x.Text
    ObjCmd.Paramete rs.Add("@trvlli ngft", Data.SqlDbType. Text).Value = trvllingftCombo Box.Text
    ObjCmd.Paramete rs.Add("@pssnge rAD", Data.SqlDbType. Text).Value = pssngerADTextBo x.Text
    ObjCmd.Paramete rs.Add("@phoneN o", Data.SqlDbType. Int).Value = phoneNoTextBox. Text
    ObjCmd.Paramete rs.Add("@fare", Data.SqlDbType. Int).Value = fareTextBox.Tex t
    ObjCmd.Paramete rs.Add("@time", Data.SqlDbType. Text).Value = timeTextBox.Tex t
    ObjCmd.Paramete rs.Add("@exptdj d", Data.SqlDbType. Text).Value = exptdjdTextBox. Text
    ObjCmd.Paramete rs.Add("@date", Data.SqlDbType. Text).Value = dateTextBox.Tex t


    Objbtn.ExecuteN onQuery()


    Objconn.Close()
    End Sub[/CODE]
  • TRScheel
    Recognized Expert Contributor
    • Apr 2007
    • 638

    #2
    Instead of:

    [code=vbnet]
    ObjCmd = New SqlCommand(...)
    [/code]

    try

    [code=vbnet]
    Dim ObjCmd As SqlCommand = New SqlCommand(...)
    [/code]

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Hi Menyki,

      I have changed the title of your thread to better reflect the problem that you are facing. In the future could you please use more descriptive titles;this will help everyone to help you. Please review the posting guidelines for reasons why you should use good titles and other general rules that we follow here on theScripts.

      Thanks,
      -MODERATOR

      Comment

      Working...