Friday, April 30, 2010

Select data using SqlCommand


Select data using sqlcommand

selectButton event
It is step3 procedure

protected void btn_select_Click(object sender, EventArgs e)
    {

        sqlgetdata getdata=new sqlgetdata();

       classvar seletvar= getdata.searchmain(Convert.ToInt32(TextBox1.Text));

       TextBox2.Text = Convert.ToString(seletvar.name);
       TextBox3.Text = Convert.ToString(seletvar.course);
       TextBox4.Text = Convert.ToString(seletvar.fee);

        Label1.Text = "record fetched";

    }




Variable class


It is step4 procedure


public class classvar
{
    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 classvar searchmain(Int32 ss)
    {
        Int32 sa = ss;
        string sqlquerystring= "select * from student where stu_id="+ sa;

       
             string sqlconstring= "Data Source= SHYAM-6E8C5C74B\\SQLEXPRESS ;initial catalog=college; integrated security=True ";
 SqlConnection sqlcn= new SqlConnection(sqlconstring);

Sqlcommand sqlcmd=new Sqlcommand(sqlquerystring,sqlcn);
sqlcn.Open();
SqlDataReader sqlre= sqlcmd.ExecuteReader();
        classvar seletvar = new classvar();
        while (sqlre.Read())
        {
            seletvar.fee = re["fee"].ToString();
            seletvar.name = re["name"].ToString();
            seletvar.course = re["course"].ToString();


        }
            sqlre.Close();
           sqlcn.Close();
        return seletvar;
}














See Status of the blog



13 comments:

shyam parmar said...

http://mayurdharukiya.com/

myresume,developer,iphone,android,blackberry,india

shyam parmar said...

http://www.50states.com/"

50 States and Capitals

dipakkumar said...

This is a very nice information and too useful for me on my project work.

Get Free Gift

Anonymous said...

Just want to say what a great blog you got here!
I've been around for quite a lot of time, but finally decided to show my appreciation of your work!

Thumbs up, and keep it going!

Cheers
Christian, iwspo.net

Anonymous said...

Just want to say what a great blog you got here!
I've been around for quite a lot of time, but finally decided to show my appreciation of your work!

Thumbs up, and keep it going!

Cheers
Christian, iwspo.net

Anonymous said...

xanax online round white generic xanax - xanax withdrawal after one dose

Anonymous said...

buy tramadol online tramadol no prescription cod - tramadol hcl and xanax

Anonymous said...

xanax online 2mg klonopin 2mg xanax - xanax for anxiety and insomnia

Anonymous said...

tramadol without prescription tramadol er 100mg - can buy tramadol online legally

Anonymous said...

generic xanax xanax side effects tinnitus - xanax just makes me sleepy

Anonymous said...

buy tramadol online tramadol legal to buy online - tramadol hcl 50 mg tablet side effects

Anonymous said...

generic xanax xanax no prior prescription - xanax withdrawal pain

Anonymous said...

buy tramadol online ultram better than tramadol - tramadol for dogs cost