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

Answers were Sorted based on User's Feedback



how find recored from the database..

Answer / 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

how find recored from the database..

Answer / 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

More Dot Net WindowsForms Interview Questions

What are windows based applications examples?

0 Answers  


What is form design?

0 Answers  


Are windows forms still used?

0 Answers  


Where is system windows forms dll?

0 Answers  


Which window allows viewing the resources of the servers, such as services, processes and the event log?

0 Answers  


What are window applications?

0 Answers  


how save recoreed in the database

4 Answers   Wipro,


Which dialog box allows users to switch to another area of the application?

0 Answers  


what is acomponent in windows applications?

2 Answers  


What are window based applications?

0 Answers  


Name the two main categories of .net components.

0 Answers  


What is the need of tabindex property is label control?

1 Answers  


Categories