Created
May 11, 2018 16:03
-
-
Save seanghay/820d052ac87911cc0ac03ec79d02705a to your computer and use it in GitHub Desktop.
C# Connect To Access Database
This file contains 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
try { | |
OleDbConnection connection = new OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=C:\\Users\\Seanghay\\Documents\\Students.accdb"); | |
connection.Open(); | |
OleDbDataAdapter adapter = new OleDbDataAdapter("select * from TableStudent", connection); | |
DataTable table = new DataTable(); | |
adapter.Fill(table); | |
table.DefaultView.RowFilter = "Gender='male'"; | |
dataGridView1.DataSource = table; | |
} catch(Exception ex) { | |
Console.WriteLine(ex.Message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment