1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59:
| public partial class Form1 : Form { public Form1() { InitializeComponent(); } private OleDbDataAdapter da; private OleDbDataAdapter daa; private DataTable dt; private DataTable dtt; private BindingSource bs = new BindingSource(); private BindingSource bss = new BindingSource();
public void Form1_Load(object sender,EventArgs e) { Start(sender, e); } public void Start(object sender, EventArgs e) { string connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Akten.mdb;"; OleDbConnection conn = new OleDbConnection(connStr);
if (radioButton1.Checked == true) { string ab = "Akte1"; string selStr = "SELECT LaufNr,Reihe,stock1,stock2,stock3,stock4 FROM Akte1"; OleDbCommand cmd = new OleDbCommand("SELECT *FROM Akte1", conn); da = new OleDbDataAdapter(selStr, conn); OleDbCommandBuilder cb = new OleDbCommandBuilder(da); da.SelectCommand = new OleDbCommand(selStr, conn); dt = new DataTable(ab); conn.Open(); da.Fill(dt); conn.Close(); bs.DataSource = dt; textBox20.DataBindings.Add("Text", bindingSource1, "Reihe"); bindingSource1.DataSource = dt; dataGridView1.DataSource = dt; } if (radioButton2.Checked == true) { string ab = "Akte2";
string selStr = "SELECT LaufNr,Reihe,stock1,stock2,stock3,stock4 FROM Akte2"; OleDbCommand cmd = new OleDbCommand("SELECT *FROM Akte2", conn); daa = new OleDbDataAdapter(selStr, conn); OleDbCommandBuilder cb = new OleDbCommandBuilder(daa); daa.SelectCommand = new OleDbCommand(selStr, conn); dtt = new DataTable(ab); conn.Open(); daa.Fill(dtt); conn.Close(); bss.DataSource = dtt; textBox20.DataBindings.Add("Text", bindingSource2, "Reihe"); bindingSource2.DataSource = dtt; dataGridView1.DataSource = dtt; } } |