Results 1 to 8 of 8

Thread: [2005] Add records to a MDB file [RESOLVED]

  1. #1

    Thread Starter
    Member kashi_rock's Avatar
    Join Date
    Apr 2006
    Location
    Delhi (India)
    Posts
    55

    Question [2005] Add records to a MDB file [RESOLVED]

    Hi Friends,

    I am using VB2005 Express Edition but I m quite new to this version. I have some text strings in combo boxes & I have a output.mdb having a table called as data. Now I want to add those values into my table.
    Can any one please help me out to pull me up from this dark side

    Regards
    Kashi
    Last edited by kashi_rock; Apr 21st, 2006 at 03:48 AM.

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

    Re: [2005] Add records to a MDB file

    There are a number of tutorials in my signature that are either ADO.NET-specific or have ADO.NET sections. The Start VB.NET site even has a section dedicated to ADO.NET with Access, but any ADO.NET information is directly relevant.
    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

    Thread Starter
    Member kashi_rock's Avatar
    Join Date
    Apr 2006
    Location
    Delhi (India)
    Posts
    55

    Re: [2005] Add records to a MDB file

    hi jmcilhinney,
    Thx for the guidence. Can you provide some source code for my better understanding.
    Looking for your best support.

    Thx. Kashi

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

    Re: [2005] Add records to a MDB file

    Source code here, where I suggested: http://www.startvbdotnet.com/ado/msaccess.aspx
    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

  5. #5

    Thread Starter
    Member kashi_rock's Avatar
    Join Date
    Apr 2006
    Location
    Delhi (India)
    Posts
    55

    Re: [2005] Add records to a MDB file

    hi jmcilhinney,
    I have tried the code as you have suggested, but didn't found the success. Can you please write some code for my problem. I know I am taking your valuable time but please help me.
    I have "Sheet_data.mdb" & I want to insert the records from "combobox1,2,3,4" into table "Data".
    Using VB2005
    Thx. Kashi

  6. #6

    Thread Starter
    Member kashi_rock's Avatar
    Join Date
    Apr 2006
    Location
    Delhi (India)
    Posts
    55

    Re: [2005] Add records to a MDB file

    hello all,
    I have tried following code to insert records (projectname, projectcode, activityname, activitycode) from various combo boxes in table Data for sheet_data.mdb.
    But Still I can not get the right things. Please suggest me where I m doing wrong:

    Imports System.Data.OleDb
    Public Class MainWindow
    Dim connection As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\sheet_data.mdb")
    Dim cmd As OleDbCommand
    Dim icount As Integer
    Dim str As String
    Try
    connection.Open()
    str = "insert into data (projectname,projectcode,activityname,activitycode) values('" & ComboBox1.SelectedText & "'" & ComboBox3.SelectedText & "'" & ComboBox2.SelectedText & "'" & ComboBox4.SelectedText & ")"
    cmd = New OleDbCommand(str, connection)
    icount = cmd.ExecuteNonQuery
    MessageBox.Show(icount)
    Catch ex As Exception
    End Try
    connection.Close()
    End Sub
    End Class
    Thx.
    Kashi

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

    Re: [2005] Add records to a MDB file

    You misunderstand what the SelectedText property does.

    http://www.vbforums.com/showthread.p...t=selectedtext
    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

  8. #8

    Thread Starter
    Member kashi_rock's Avatar
    Join Date
    Apr 2006
    Location
    Delhi (India)
    Posts
    55

    Re: [2005] Add records to a MDB file [RESOLVED]

    hi jmcilhinney,
    You have catched the exactly the right error. Actually I was not correctly getting the combobox values. But now its working fine.

    Thx for your kind support.
    Kashi

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