Last active
November 11, 2018 10:59
-
-
Save canokay/753286c046b7685680aa8713fe537536 to your computer and use it in GitHub Desktop.
C # Database Connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using System.Data; | |
using System.Data.OleDb; | |
namespace Ders1Uygulama1 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
OleDbConnection baglan; // Bağlantı işlemi sırasında kullanılan connection nesnesi | |
OleDbDataAdapter verial; // dataset veri aktaracak DataAdapter nesnesi | |
DataSet al; //DataGridWiew'a veri aktaracağımız on bellek | |
string baglanti, sorgu; //baglanti ve sorgu degiskenleri | |
baglanti = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=veritabani.mdb"; | |
sorgu = "select * from ogr"; //SQL Sorgusu | |
baglan = new OleDbConnection(baglanti); //Connectiona baglanti stringi yollma | |
verial = new OleDbDataAdapter(sorgu, baglan);// adapter nesnesi sorgu ve baglanı yokkadık; | |
al = new DataSet(); | |
verial.Fill(al, "ogr");//DataSet icine doldurulur. | |
dataGridView1.DataSource = al.Tables[0];//Veri DataGridView'a aktarılır. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment