Veritabanı Bilgi Çekme

Veritabanından veri çekme

Veritabanından veri çekme. Bilgi Arama örneği.

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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
oleDbConnection1.Open();
string sorgu = “select * from personel where adı='”+textBox1.Text+”‘”;
OleDbDataAdapter adp = new OleDbDataAdapter(sorgu,oleDbConnection1);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
textBox2.Text = ds.Tables[0].Rows[0][0].ToString();
textBox3.Text = ds.Tables[0].Rows[0][2].ToString();
}
else
textBox2.Text = “Veri yok “;
oleDbConnection1.Close();
}
}
}

admin