Re: data base

Chirag Bhavsar replied to somnath Chakraborty at 10-May-08 05:03

these are the basic Steps

1.Connect to database(IDbConnection) SQlConnection

2.Execute SQL command object(IDbCommand) SqlCommand

3.Read and compute (IDataReader) SqlDataReder

4.Release resources

 

usingSystem.Data;....
1.) Declare connection;
try
{ 
   // optional 1.) Create connection to data source;
   2.) Execute SQL commands;
   3.) Compute result;
   4.) Release resources;
} 
catch( Exception )   
{
Handle exception or dispatch it;
} 
finally
{
   try
   { 
      // optional4.) Close connection;
   } catch(Exception) { Handle exception; }
}
 

IDataReader ExecuteReader(...)//Property CommandTextonly contains SQL SELECT statements

Int ExecuteNonQuery() //Property CommandTextcontains INSERT, UPDATE, DELETE, ...

cmd.CommandText= "UPDATEEmplsSETCity = ’Seattle’ WHERElD=8";

intaffectedRows= cmd.ExecuteNonQuery(); 

IDbCommandcmd= newSqlCommand("SELECTcount(*) FROM Empls",new SqlConnection(connStr));
cmd.Connection.Open();
intcount = (int) cmd.ExecuteScalar();
cmd.Connection.Close();

Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  data base connuction - somnath Chakraborty  10-May-08 03:19 3:19:43 AM
      go thru this.. - santhosh kapa  10-May-08 03:26 3:26:07 AM
      check here - Vasanthakumar D  10-May-08 04:33 4:33:26 AM
      Database conn - Sujit Patil  10-May-08 04:57 4:57:13 AM
      Try this - sri sri  10-May-08 04:52 4:52:41 AM
      Re: data base - Chirag Bhavsar  10-May-08 05:03 5:03:07 AM
View Posts