Database INSERT statement

Discussion in 'ASP .Net' started by Sparky Arbuckle, Aug 31, 2005.

  1. I can't for the life of me figure out why this won't insert into my
    database. I'm also not getting any errors when I run this. I've even
    tried inside a TRY CATCH block and still nothing. I've run this web app
    numerous times and each time I check the database, nothing is there! I
    must be missing something small here.

    Private Sub btnSubmitDLNumber_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles btnSubmitDLNumber.Click

    Dim strDL As String = tbDL.Text

    Dim objConn As New
    OleDb.OleDbConnection(ConfigurationSettings.AppSettings("strConnection"))
    Dim strSQL As String = "INSERT INTO tblDL (DLNumber, DateAdded) VALUES
    ('" & strDL & "', " & Now & ");"

    Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)

    End Sub
     
    Sparky Arbuckle, Aug 31, 2005
    #1
    1. Advertising

  2. Sparky Arbuckle

    Marina Guest

    You are never actually executing the query. All you do is create an
    OleDbCommand object with the query text. But that's it.

    You need to open the connection, run the query, then close the connection.

    "Sparky Arbuckle" <> wrote in message
    news:...
    >I can't for the life of me figure out why this won't insert into my
    > database. I'm also not getting any errors when I run this. I've even
    > tried inside a TRY CATCH block and still nothing. I've run this web app
    > numerous times and each time I check the database, nothing is there! I
    > must be missing something small here.
    >
    > Private Sub btnSubmitDLNumber_Click(ByVal sender As System.Object,
    > ByVal e As System.EventArgs) Handles btnSubmitDLNumber.Click
    >
    > Dim strDL As String = tbDL.Text
    >
    > Dim objConn As New
    > OleDb.OleDbConnection(ConfigurationSettings.AppSettings("strConnection"))
    > Dim strSQL As String = "INSERT INTO tblDL (DLNumber, DateAdded) VALUES
    > ('" & strDL & "', " & Now & ");"
    >
    > Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)
    >
    > End Sub
    >
     
    Marina, Aug 31, 2005
    #2
    1. Advertising

  3. LOL! I shouldn't have drank last night!
     
    Sparky Arbuckle, Aug 31, 2005
    #3
  4. Sparky Arbuckle

    Pat Guest

    Drinking is good but at the right time..
    And the funniest thing is that i see more of .Net when drink:)

    "Sparky Arbuckle" <> wrote in message
    news:...
    > LOL! I shouldn't have drank last night!
    >
     
    Pat, Sep 1, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    817
  2. Jay McGavren
    Replies:
    11
    Views:
    1,159
    Alan Krueger
    Jan 16, 2006
  3. tedsuzman
    Replies:
    2
    Views:
    7,128
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  4. Ted
    Replies:
    1
    Views:
    479
    Duncan Booth
    Jul 22, 2004
  5. J. Muenchbourg
    Replies:
    3
    Views:
    250
    Aaron Bertrand - MVP
    Sep 30, 2003
Loading...

Share This Page