Results 1 to 3 of 3

Thread: inseting data to ms access error

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    8

    inseting data to ms access error

    hi i'm new to vb.net. i'm using visual studio 2005 windows application vb.net language. i'm doing a company project and using MS access database.
    i want the user to add data about the new customer and save it to the database.i used the followinf code:
    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. Dim dbconnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "data source=C:\Users\becool\Desktop\customer list\New Farahnet\FarahnetCustomers.mdb"
    3.  
    4. Dim dbcommand As String = "INSERT into customers (Fname, Lname, IP, Telephone, Email, Location, TypeocConnection, Download, Upload, StartDate, StoppedDate) " & " VALUES ('Textbox1.text','Textbox2.text','Textbox3.text','Textbox 4.text','Textbox5.text','Textbox6.text','Textbox7.text','Textbox8.text','Textbox9.text','Textbox10.text','Textbox11.text')"
    5.  
    6. Dim DataAdapterTest As New OleDb.OleDbDataAdapter(dbcommand, dbconnection)
    7.  
    8. Dim customersDataSet As New DataSet()
    9.  
    10. [U]DataAdapterTest.Fill(customersDataSet)[/U]
    11.  
    12. Dim dtcustomers As DataTable = customersDataSet.Tables(0)
    13.  
    14. End Sub
    but i get an error on the underlined line above.can anyone please tell me if there is anything wrong with it?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: inseting data to ms access error

    The Fill method retrieves data from the database; it doesn't save data. Follow the Database FAQ link in my signature and check out the .NET section for resources. The second link in that section is my own ADO.NET code examples that show you how to implement the most common scenarios.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: inseting data to ms access error

    In addition, when you get an error in your code, it is always beneifical to explicity state what that error is when asking for assistance.

    Thanks.

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