Public paste
test
By: test | Date: Jan 12 2010 15:44 | Format: None | Expires: never | Size: 1.71 KB | Hits: 456

  1. #region how to work with firebird database
  2.         FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
  3.  
  4.         builder.DataSource = "localhost";
  5.         builder.Database = "C:\Development\READERDATABASE.FDB";
  6.         builder.UserID = "SYSDBA";
  7.         builder.Password = "masterkey";
  8.         builder.Charset = "UTF8";
  9.  
  10.         using (FbConnection connection = new FbConnection(builder.ToString()))
  11.         {
  12.             connection.Open();
  13.  
  14.             using (FbCommand command = connection.CreateCommand())
  15.             {
  16.                 #region to build a command
  17.                 //OR
  18.                 command.CommandText = "SELECT * FROM table WHERE field = ?";
  19.  
  20.                 command.Parameters.Add(new FbParameter() { Value = 23});
  21.  
  22.                 //OR
  23.                 command.CommandText = "PROCEDURENAME";
  24.  
  25.                 command.CommandType = System.Data.CommandType.StoredProcedure;
  26.                 command.Parameters.Add(new FbParameter() { Value = 23 });
  27.                 #endregion
  28.  
  29.                 #region To execute a command
  30.                 // No return values
  31.                 command.ExecuteNonQuery();
  32.  
  33.                 // 1 value (or 1st value of 1st row)
  34.                 string scalarValue = command.ExecuteScalar().ToString();
  35.  
  36.                 // Data reader (table)
  37.                 using (FbDataReader reader = command.ExecuteReader())
  38.                 {
  39.                     while (reader.Read())
  40.                     {
  41.                         string strResult = reader[0].ToString();
  42.                         int intResult = Int32.Parse(reader[1].ToString());
  43.                     }
  44.                 }
  45.                 #endregion
  46.             }
  47.         }
  48.         #endregion
Latest pastes
8 minutes ago
7 hours ago
6 days ago
18 days ago
23 days ago