Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.OleDb;
- namespace conexaoAccess
- {
- class Program
- {
- static void Main(string[] args)
- {
- OleDbConnection conexao = new OleDbConnection(@"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Victor\Documents\exemplo.mdb");
- OleDbCommand sql = new OleDbCommand("select * from bairro", conexao);
- try
- {
- conexao.Open();
- OleDbDataReader lendo_dados = sql.ExecuteReader();
- while (lendo_dados.Read())
- {
- Console.WriteLine(lendo_dados.GetString(1));
- Console.WriteLine(lendo_dados.GetString(2) + "\n");
- }
- Console.WriteLine("Fim da lista");
- Console.ReadKey();
- lendo_dados.Close();
- conexao.Close();
- }
- catch (OleDbException erro_oledb)
- {
- Console.WriteLine(erro_oledb.Message);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment