Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how find recored from the database

Answer Posted / venky

Dear friend my answer is relating to csharp.net....SQLSERVER Database.

TO get records from database

1) our Application have to Connect with database.

SQlconnection cn=new sqlconnectio(@"server=.\SQLEXPRESS;Database=mydatabase;Integrated Security=SSPI");
cn.open();

2) we have to prepare COMMAND object Which encapsulate a sql statement and connection obj.


SQLCommand cmd=new Sqlcommand("select * from table1",cn);

then we call following method to get records

SqlDataReader rdr= cmd.ExecuteReader(CommandBehavior.CloseConnection);
int f_cnt= rdr.FieldCount;
Type t= rdr.GetFieldType(1);

while(rdr.Read())
{
int cou = rdr.FieldCount;
for(int i1=0;i1<cou;i1++)
{


string s2 = rdr.GetValue(i1).ToString();
ans = ans + " " + s2+" ";


}
i++;
ans = ans + "\n";

}
MessageBox.Show(ans);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how print PGL by XML

2995


Explain about crystal report in brief?

949


What is form and its uses?

959


Which property is used to specify the use of an element in the user interface and reports it to the accessibility aids?

1016


Explain how insert record in the database?

1028


What is the difference between a document and a form?

998


Name the property which is used to specify the source from where the crystal reports would be accessed.

990


How many navigational features are provided by visual studio.net ide?

1042


What is the use of play() playlooping() functions?

1050


How to split a column header in gridview using c#.net?

1231


Name the event that enables the user to prevent shifting of focus from control until all the validation rules have been met.

923


How is anchoring different from docking?

1183


What is a windows form application?

981


how barcode print on the win form

2408


What are the properties of datacontrol?

2508