how find recored from the database

Answer Posted / eric

You mean: "How do I get records from a database?"

You have to get the "dotnet driver" of the database (or any
other datasource) you want to access to.

For example:
MySQL: Connector/Net
Access: Microsoft Access Driver
Oracle: Oracle Data Access Components (ODAC)

Afterwards you build a connection string to tell your
programm which driver you want to use and where the
datasource can be found, for example:

public const string DB_CONN_STRING =
"Driver={Microsoft Access Driver (*.mdb)}; "+
"DBQ=D:\\CS\\TestDbReadWrite\\SimpleTest.mdb";

Afterwards you just have to open a connection to the
database using the previously created connection string and
send a query to the database to get the record:

ADOConnection conn = new ADOConnection(DB_CONN_STRING);
conn.Open();
ADODataReader dr;
ADOCommand cmd = new ADOCommand( "SELECT * FROM <table>",
conn );
cmd.Execute(out dr);
while (dr.Read()){
....}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the synonym of form?

516


how see report periviwe

2337


Which window displays messages for the status of various features provided in the visual studio .net ide?

558


Which method grants a lock on a resource?

579


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

559






What is the extension of the windows installer file?

579


Explain the need of z-order method?

520


What is the difference between desktop application and windows application?

492


What is difference between winforms and windows forms?

579


Which method of the messagebox class is used to display a message in the message box?

565


Explain how many number of events does the timer controls?

529


Name the method that has to be overridden to change the appearance of the control that is inherited from an existing control.

570


Name the two main categories of .net components.

536


Is form action required?

515


Name the template that is used to create a user-defined component.

520