Code
Code
Code
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.SqlClient;
namespace Activity_Simple_System
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\
v11.0;AttachDbFilename=E:\Alarms\Jomar Basic System\Activity Simple System\
Activity Simple System\Database2.mdf;Integrated Security=True");
public Form1()
{
InitializeComponent();
}
}
public void display_data()
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from [Table]";
cmd.ExecuteNonQuery();
DataTable dta = new DataTable();
SqlDataAdapter dataadp = new SqlDataAdapter(cmd);
dataadp.Fill(dta);
dataGridView1.DataSource = dta;
con.Close();
}
private void button3_Click(object sender, EventArgs e)
{
display_data();
}
}
}
}