Şekil 1
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection baglan = new OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0;Data
Source= northwind.accdb");
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand();
DataSet ds = new DataSet();
baglan.Open();
cmd.CommandText = "Select ID, FirstName,LastName,JobTitle,City From
Customers ";
da.SelectCommand = cmd;
cmd.Connection = baglan;
da.Fill(ds, "Customers");
comboBox1.DataSource = ds;
comboBox1.DisplayMember = "Customers.ID";
//combobox
ta seçili id deki müşteri bilgilerini textboxta gösteriyoruz.
this.textBox1.DataBindings.Add("Text", ds, "Customers.ID");
this.textBox2.DataBindings.Add("Text", ds, "Customers.FirstName");
this.textBox3.DataBindings.Add("Text", ds, "Customers.LastName");
this.textBox4.DataBindings.Add("Text", ds, "Customers.JobTitle");
this.textBox5.DataBindings.Add("Text", ds, "Customers.City");
baglan.Close();
}
}
}
0 comments:
Yorum Gönder