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
Name the property which is used to lock a textbox to enter data?
Name the class to be inherited for creating a custom control.
To which namespace does the control class belong?
What are windows applications?
Explain how to split a column header in gridview using c#.net?
Name the event that enables the user to prevent shifting of focus from control until all the validation rules have been met.
Which event occurs when a user drags an item in a treeview or listview control?
What is formdata?
How can you pause a timer control?
What is the extension of a compiled help project file?
What is form and its uses?
What are the three states set in a checkstate property?
What is the use of play() playlooping() functions?
What are window applications?
What is window form application?