I am new to vb.net .
I have tables with different names but same columns name.I would like to know how do i insert text box values into combobox selected table ?
any bit of info would be helpful
I have tables with different names but same columns name.I would like to know how do i insert text box values into combobox selected table ?
any bit of info would be helpful
Code:
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load
con.Open()
Me.ComboBox1.DisplayMember = "TABLE_NAME"
Me.ComboBox1.ValueMember = "TABLE_NAME"
Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES", New String() {Nothing, Nothing, Nothing, "TABLE"})
con.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb2.accdb")
Dim CmdStr As String = "insert into table1 (a,b,c) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
con.Open()
Dim cmd As OleDbCommand = New OleDbCommand(CmdStr, con)
cmd.ExecuteNonQuery()
con.Close()
MsgBox("Done")
End Sub