Code To SELECT in Access Db using c#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FirstDBApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection n = new SqlConnection();
            n.ConnectionString = "Data Source=.;Initial Catalog=\"Scannet Features\";Integrated Security=True";
            n.Open();

            SqlCommand d = new SqlCommand();
            d.Connection = n;
            d.CommandText = "Select * from library"
;
            SqlDataReader reader = d.ExecuteReader();
            while (reader.Read())
            {
                string s = (String)reader["DocumentName"];
                MessageBox.Show(s);
            }

        }
    }
}

Yorumlar

Popüler Yayınlar