It is step3 procedure
Delete Button code
protected void btn_delete_Click(object sender, EventArgs e)
{
datac b = new datac();
b.delete(Convert.ToInt32(TextBox1.Text));
//control of asp.net
Label1.Text = "record deleted";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
}
It is step5 procedure.
This class actually work on data here it is work on deleting data
Delete Data class
public void deletemain(Int32 ss)
{
//simple delete query
//To insert data we just change the query.
string query = "delete from student where stu_id=" + ss;
// we can write query using logical operator also.
///////
//connection string
string constring = "Data Source= SHYAM-6E8C5C74B\\SQLEXPRESS ;initial catalog=college; integrated security=True ";
//Creating Connection
SqlConnection cn = new SqlConnection(constring);
SqlDataAdapter da = new SqlDataAdapter(query, cn);
DataSet ds = new DataSet();
da.Fill(ds);
}
Get 1 Million Hits, FREE!
This unique and revolutionary model allows you to Learn and Grow, ... knowledge and has been able to put it to constructive use, to earn one's livelihood. ...
Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts
Sunday, March 21, 2010
Saturday, March 20, 2010
Select data using (DATA SET)ds and dt
It is step3 procedure
protected void btn_select_Click(object sender, EventArgs e)
{
Datac c=new datac();first f= c.search(Convert.ToInt32(TextBox1.Text));TextBox2.Text = Convert.ToString(f.name);TextBox3.Text = Convert.ToString(f.course);TextBox4.Text = Convert.ToString(f.fee);
Label1.Text = "record fetched";
}
It is step4 procedureVariable class
public class first{public int id{get;set;}
public string name { get; set; }public string course { get; set; }public int fee { get; set; }}
It is step5 procedure
public first searchmain(Int32 ss)
{
Int32 sa = ss;
string querystring= "select * from student where stu_id="+ sa;
first f = new first();
string constring = "Data Source= SHYAM-6E8C5C74B\\SQLEXPRESS ;initial catalog=college; integrated security=True "
SqlConnection cn = new SqlConnection(constring);
SqlDataAdapter da = new SqlDataAdapter(querystring,cn);
DataSet ds = new DataSet();
da.Fill(ds);
f.name = Convert.ToString(ds.Tables[0].Rows[0][1]);
f.course = Convert.ToString(ds.Tables[0].Rows[0][2]);
f.fee = Convert.ToInt32(ds.Tables[0].Rows[0][3]);
return f;
}
Simple Insert data using (DATA SET)ds and dt
Save button event
protected void btn_save_Click(object sender, EventArgs e){
first f = new first();f.id = Convert.ToInt32(TextBox1.Text);f.name = TextBox2.Text;f.course = TextBox3.Text;f.fee = Convert.ToInt32(TextBox4.Text);
datac c=new datac();c.insertmain(f);Label1.Text = "record inserted";}
Variable class
public class first{
public int id{get;set;}
public string name { get; set; }public string course { get; set; }public int fee { get; set; }}
Data class
public void insertmain(first f){string query = "Insert into student values(" + f.id + ",'" + f.name + "','" + f.course + "'," + f.fee + ")";
string constring = "Data Source= SHYAM-6E8C5C74B\\SQLEXPRESS ;initial catalog=college; integrated security=True "
SqlConnection cn = new SqlConnection(constring);
SqlDataAdapter da = new SqlDataAdapter(query,cn);
DataSet ds = new DataSet();
da.Fill(ds);
}
Add your website to our directory to get more visitors.
increase your webtraffic
Subscribe to:
Posts (Atom)