You are on page 1of 2

Balen salman

using System;
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
sqlconnection conn = new sqlconnection(""Data Source=DESKTOP-
H4DN4EG\\SQLEXPRESS;Initial Catalog=Retail;Integrated Security=True);

public void showdata{


con.IDbConnection();
SqlCommand Cmd=New SqlCommand("insert into login
(name=@name,password=@pass)",Connection.conn);
SqlDataAdapter da=New SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill (ds,"Login");
dataGridView1.DataSource=ds.["Login"];
conn.dbclose();

private void insert_Click(object sender, EventArgs e)


{
con.dbconnect();
SqlCommand cmd=new SqlCommand("insert into Login
(name,password)values(@name,@pass)",connection.conn);
cmd.Parameters.AddWithValue("@name",textBox1.Text);
cmd.Parameters.AddWithValue("@pass",textBox2.Text);
cmd.ExecuteNonQuery();
con.dbclose();
showdata();

private void search_Click(object sender, EventArgs e)


{
con.IDbConnection();
SqlCommand Cmd=New SqlCommand("select*into Login where
id=@id",Connection.conn);
SqlDataAdapter da=New SqlDataAdapter(cmd);
DataSet ds=new DataSet();
cmd.ExecuteNonQuery();
con.dbclose();
showdata();
}
} }
Sql
create database Retail
use Retail
craete table Login
use Login(
varchar username(100)null
varchar password(100)null
varchar their role()

insert into Login(


(name,password,)
valiues(name,pass)
);

);

create table products


use products(
int id ()null;
varchar product name()null;
varchar sellprice()null;
)
insert into products(name,id,sellprice,prudactname
value());

create table sold product;


use sold products
varchar name()null;
varchar productid()null;
varchar date of sell()null;
insert into products(name,productid,sell,
value())

You might also like