Programs
Programs
net
ado.net history
temporary :-
Ado.net :
txtrn
txtname
txtage
txtcourse
btnclear
btnsave
btndelete
btnsearch
btnupdate
STEP 3
make connection string
how to add tabel right click on database name then rigt click on tables folder then you will process
ahead
give name to your database
followo the rules while givivng databse name and table name ok
refresjh your database form serverexplorer then see inside table foder category yiour table has created
done
click
step 3 :- make connection string
how
steps
add your sqlserver here in visual studion server explorer window
how to that
now start writitng code in form .cs file for everything insert update delete serch,clear ok
using System.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace adodemos
{
public partial class txtname : Form
{
SqlConnection conn;
SqlCommand comm;
SqlDataReader dreader;
string connstring = @"Data Source=THN01-06\SQLEXPRESS;Initial
Catalog=College;Integrated Security=True";
public txtname()
{
InitializeComponent();
}
//SEARCH CODE
private void btnsearch_Click(object sender, EventArgs e)
{
conn = new SqlConnection(connstring);
conn.Open();
comm = new SqlCommand("select * from student_detail where roll_no = " + txtrn.Text
+ " ", conn);
try
{
dreader = comm.ExecuteReader();
if (dreader.Read())
{
textBox2.Text = dreader[1].ToString();
txtage.Text = dreader[2].ToString();
txtcourse.Text = dreader[3].ToString();
}
else
{
MessageBox.Show(" No Record");
}
dreader.Close();
}
catch (Exception)
{
MessageBox.Show(" No Record");
}
finally
{
conn.Close();
}
}