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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    INSERT Statement nightmare

    Hey All,

    Im using MS Visual Web Developer with an Access Database, i am trying to enter a new row of data into a database via a select statment attached to a button_click event. the code i am using looks something like this.

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Me.AccessDataSource2.SelectCommand = "INSERT INTO [Tblissues] ([IssueDate], [IssueTime], [PlantLocation], [MachineName]) VALUES ('12/9/06', '3:00 PM', 'Gville', 'Snack2')"

    End Sub



    that being said. when i click the button, NOTHING happens, no error and no insert!!!


    I did test the connection to the Database and its fine, i can do an update and i can read the data that exists in the database i just cant insert a new row.

    This is not the first time i have delt with INSERT statments but this has me at my whits end and any help would be great.

    Thanks

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

    Duh!!

    For those interested i answered my own question. the problem was that i was creating the INSERT statement but never executing it DUH!!.

    Here is the updated code that works:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim sqlinsert
    sqlinsert = "INSERT INTO [Tblissues] ([IssueDate], [IssueTime], [PlantLocation], [MachineName]) VALUES ('12/9/06', '3:00 PM', 'Gville', 'Snack2')"

    Try
    Me.AccessDataSource2.InsertCommand = sqlinsert
    Me.AccessDataSource2.Insert()
    Catch Ex As Exception
    MsgBox(Ex.ToString)
    End Try

    End Sub


    Thanks anyway, and maybe this post will help someone in the future.


  •  

    Posting Permissions

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