Software utama/MAIN
|
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 coba4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
string constr = "data
source=ACER-PC\\SQLEXPRESS;database = hr;integrated security = SSPI";
SqlConnection consql = new SqlConnection(constr);
try
{
consql.Open();
string cmd = "select*from
tblEmployees";
SqlDataAdapter dataadapter = new SqlDataAdapter(cmd, consql);
SqlCommandBuilder commandbuilder = new SqlCommandBuilder(dataadapter);
DataTable table = new DataTable();
dataadapter.Fill(table);
dataGridView1.DataSource =
table;
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
consql.Close();
}
Tidak ada komentar:
Posting Komentar