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;
using System.IO;
namespace UseStoreProcedure
{
public partial class Form1 : Form
{
SqlCommand cmd;
SqlConnection con;
SqlDataAdapter da;
DataSet ds;
SqlDataReader dr;
public Form1()
{
InitializeComponent();
con = new SqlConnection(@"Data Source=SUSHIL-PC\SQLEXPRESS;Initial Catalog=CreateStoreProcedure;Integrated Security=True");
con.Open();
}
private void btninsert_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("EXECUTE InsertD @Name, @Address", con);
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd.Parameters.Add("@Name", SqlDbType.Char, 20).Value=txtname.Text;
cmd.Parameters.Add("@Address", SqlDbType.VarChar, 50).Value = txtaddress.Text;
int a= cmd.ExecuteNonQuery();
if (a > 0)
{
MessageBox.Show("Insert Succesfully !");
SqlCommand command = new SqlCommand("EXECUTE ShowData", con);
dr = command.ExecuteReader();
while (dr.Read())
{
listView1.Items.Add(dr["ID"].ToString());
listView1.Items.Add(dr["Name"].ToString());
listView1.Items.Add(dr["Address"].ToString());
}
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
SqlCommand command = new SqlCommand("EXECUTE ShowData", con);
dr = command.ExecuteReader();
while (dr.Read())
{
listView1.Items.Add(dr["ID"].ToString());
listView1.Items.Add(dr["Name"].ToString());
listView1.Items.Add(dr["Address"].ToString());
}
dr.Close();
}
}
}
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;
using System.IO;
namespace UseStoreProcedure
{
public partial class Form1 : Form
{
SqlCommand cmd;
SqlConnection con;
SqlDataAdapter da;
DataSet ds;
SqlDataReader dr;
public Form1()
{
InitializeComponent();
con = new SqlConnection(@"Data Source=SUSHIL-PC\SQLEXPRESS;Initial Catalog=CreateStoreProcedure;Integrated Security=True");
con.Open();
}
private void btninsert_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("EXECUTE InsertD @Name, @Address", con);
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd.Parameters.Add("@Name", SqlDbType.Char, 20).Value=txtname.Text;
cmd.Parameters.Add("@Address", SqlDbType.VarChar, 50).Value = txtaddress.Text;
int a= cmd.ExecuteNonQuery();
if (a > 0)
{
MessageBox.Show("Insert Succesfully !");
SqlCommand command = new SqlCommand("EXECUTE ShowData", con);
dr = command.ExecuteReader();
while (dr.Read())
{
listView1.Items.Add(dr["ID"].ToString());
listView1.Items.Add(dr["Name"].ToString());
listView1.Items.Add(dr["Address"].ToString());
}
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
SqlCommand command = new SqlCommand("EXECUTE ShowData", con);
dr = command.ExecuteReader();
while (dr.Read())
{
listView1.Items.Add(dr["ID"].ToString());
listView1.Items.Add(dr["Name"].ToString());
listView1.Items.Add(dr["Address"].ToString());
}
dr.Close();
}
}
}
Comments
Post a Comment