Vandana

Vandana

  • 1.2k
  • 590
  • 76.2k

how to create a method with sql in class file

Sep 7 2016 4:20 AM
hii all,
 
 
 
i have started to work on 3 tier architecture i have some problem.
 
1) I have a table name is Teamname having some data.
 
with the help of sql query i have retrived the teamname.
 
like 
 already define connection string
string query="Select Teamname from Teamname where status='ACtive'",
 
sqlcommannd cmd=new sqlcommand(query,con);
 
if(con.state==connectionstate.open()
{
con.close()
}
con.open();
sqldatareader dr=cmd.executeReader();
if(dr.hasRows())
{
returns the teamname ?????? this is how to do it
 
}
 
 
 
on another webpage onload I want to Bind it in a grid view
 
 
so how to do it. suggest me write appropriate code.
 
 
 
thanks in advance
 
 
 
 
 

Answers (2)