Start New Discussion within our Software Development Community

hey i got 2 tables named tbplayer and tbpair in database named dbgame.mdb
tbplayer has 2 field player_id and player_name..
tbpair has three field pair_id(autonumber), player_1 and player_2
i have create combobox to get player id in tbpair from tbpair.. so i don get code.. my sample code is

Imports System.Data
Imports System.Data.OleDb
 
 
Public Class frmAdd_pair
    Dim con As New OleDbConnection
    Private Sub bindpair()
        Dim adp As New OleDbDataAdapter("Select * from tbPair", con)
        Dim ds As New DataSet
        adp.Fill(ds, "pair")
 
        cmbPlayer_1.DisplayMember = "Player_ID"
        cmbPlayer_1.ValueMember = "Player_ID"
        cmbPlayer_1.DataSource = ds.Tables("player")
 
 
 
 
    End Sub
 
 
    Private Sub frmAdd_pair_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "Provider =Microsoft.Jet.OlEDB.4.0; Data Source = |DataDirectory|\dbgame.mdb; Persist Security Info = True;"
        bindpair()
 
 
    End Sub
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim cmd As New OleDbCommand
        cmd.Connection = con
        cmd.CommandType = "Insert into tbPair values ('" + cmbPlayer_1.Text + "', '" + cmbPlayer_2.Text + "')"
    End Sub
 
    Private Sub cmbPlayer_1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPlayer_1.SelectedIndexChanged
        cmbPlayer_1.Text = cmbPlayer_1.SelectedValue
 
 
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.