Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Code

The document creates a database called "Guru" and a table called "SD" within it to store student data including ID, name, gender, and address. It then defines forms and buttons to submit, update, and delete data from the student data table using ADO.NET and SQL commands.

Uploaded by

Chaitanya Dev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Code

The document creates a database called "Guru" and a table called "SD" within it to store student data including ID, name, gender, and address. It then defines forms and buttons to submit, update, and delete data from the student data table using ADO.NET and SQL commands.

Uploaded by

Chaitanya Dev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create database Guru

Create table SD
(Sid nvarchar(10),
Sname nvarchar(50),
Gender nvarchar(30),
Address nvarchar(50)
)
Select * from SD

using
using
using
using
using
using
using
using
using
using

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

namespace Sample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label3_Click(object sender, EventArgs e)

{
}
SqlConnection con = new SqlConnection("uid=sa;password=123;database=Guru");
private void btnsubmit_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into SD
values('"+txtsid.Text+"','"+txtsname.Text+"','"+cmbgender.Text+"','"+txtaddress.Text+"')",con);
cmd.ExecuteNonQuery();
MessageBox.Show("Successfully Submited...");
con.Close();
txtsid.Text = txtsname.Text = cmbgender.Text = txtaddress.Text = null;
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("update SD set Address='"+txtaddress.Text+"'
where SId='"+txtsid.Text+"'",con);
cmd.ExecuteNonQuery();
MessageBox.Show("updated...");
con.Close();
txtsid.Text = txtaddress.Text = null;
}
private void button2_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from SD where
SId='"+txtsid.Text+"'",con);
cmd.ExecuteNonQuery();
MessageBox.Show("Deleted...");
con.Close();
txtsid.Text = null;
}
}
}

You might also like