Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > .NET 4 and Visual Studio 2010 General Discussions
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET 4 and Visual Studio 2010 General Discussions For discussing anything about .NET 4, WPF, WCF, the rest of the .NET 4 Framework, and Visual Studio 2010 that isn't about a specific Wrox book. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET 4 and Visual Studio 2010 General Discussions section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 1st, 2011, 07:50 PM
Registered User
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inser data into two tables selected from two comboboxes

I was hoping someone could offer me some help please
I have a form with two comboboxes ,one text box and a button .I have multiple tables in ms access database with same structure , col1 and col2 .
I want to insert text box value into column1 in the table selected from combobox1 and into column2 in table selected from combobox2
such as if i select table1 from combobox1 and table2 from combobox2 and click on the button, data should be inserted into both table1 and table2.
I can load tables into combobox but i dont know how to handle the issue.can someone tell me (if it is possible) how can i do it
Private con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb.accdb;Persist Security Info=False")

    Private adapter As New OleDbDataAdapter(String.Empty, Me.con)
    Private data As DataTable

    Private Sub Form1_Load(ByVal sender As Object, _
                       ByVal e As EventArgs) Handles MyBase.Load

        Me.ComboBox1.DisplayMember = "TABLE_NAME"
        Me.ComboBox1.ValueMember = "TABLE_NAME"
        Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES")
        Me.ComboBox2.DisplayMember = "TABLE_NAME"
        Me.ComboBox2.ValueMember = "TABLE_NAME"
        Me.ComboBox2.DataSource = Me.con.GetSchema("TABLES")

       End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
                                           ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        If Me.ComboBox1.SelectedItem IsNot Nothing Then
            Me.data = New DataTable
            Me.adapter.SelectCommand.CommandText = String.Format("SELECT * FROM [{0}]", Me.ComboBox1.SelectedValue)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, _
                           ByVal e As EventArgs) Handles Button1.Click
        If Me.data IsNot Nothing Then
            Dim builder As New OleDbCommandBuilder(Me.adapter)
        End If
    End Sub

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
For repeated ComboBoxes Count Selected Items Borhani Excel VBA 1 March 24th, 2008 06:49 PM
Gridview for inser,update without using datasource karthikeyan_pa ASP.NET 2.0 Professional 0 September 4th, 2007 07:58 AM
inser xml data to sql server from asp ak Classic ASP Databases 7 February 25th, 2004 01:05 PM

All times are GMT -4. The time now is 02:32 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.