CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Posts
    2

    Unhappy Asp.net/vb/sql Insert

    Greetings, and thank you in advance.

    I have been trying, and failing horribly at trying to INSERT values from an <asp:TextBox> into a access database. I get no errors which leads me to believe that my insert command is wonky. I am however, able to SELECT * from TableName. I would like to do this on an <asp:button> here's my sub:

    Sub submit (sender As Object, e As EventArgs)
    dim dataconn, datacomm,sqlinsert
    dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.o;data_ source=" & "C:\....\...\Database.mdb;")

    dataconn.Open()
    sqlinsert="INSERT INTO TableName(Field1,Field2,Field3,Field4) VALUES (TextBox1.Text, TextBox2.Text...)"

    datacomm=New OleDbCommand(sqlinsert, dataconn)

    dataconn.Close()
    End Sub

    So that being said, I've tried that pesky INSERT so many different ways I'm at my wits end. And seens how I've been a week to learn a language, I have no place else to turn


    Would I have to to do a .DataBind()? or something I'm just not sure.

    Any help would be great, I only have until 9am Wednesday to finish. :/

    Thank you again in advance,
    Dave

  2. #2
    Join Date
    Aug 2007
    Posts
    30

    Re: Asp.net/vb/sql Insert

    i can't see ur are executing ur query any where in this code,
    try this

    datacomm.ExecuteNonQuery()

    after this line

    datacomm=New OleDbCommand(sqlinsert, dataconn)

    it should work..

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured