- #region how to work with firebird database
- FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
- builder.DataSource = "localhost";
- builder.Database = "C:\Development\READERDATABASE.FDB";
- builder.UserID = "SYSDBA";
- builder.Password = "masterkey";
- builder.Charset = "UTF8";
- using (FbConnection connection = new FbConnection(builder.ToString()))
- {
- connection.Open();
- using (FbCommand command = connection.CreateCommand())
- {
- #region to build a command
- //OR
- command.CommandText = "SELECT * FROM table WHERE field = ?";
- command.Parameters.Add(new FbParameter() { Value = 23});
- //OR
- command.CommandText = "PROCEDURENAME";
- command.CommandType = System.Data.CommandType.StoredProcedure;
- command.Parameters.Add(new FbParameter() { Value = 23 });
- #endregion
- #region To execute a command
- // No return values
- command.ExecuteNonQuery();
- // 1 value (or 1st value of 1st row)
- string scalarValue = command.ExecuteScalar().ToString();
- // Data reader (table)
- using (FbDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- string strResult = reader[0].ToString();
- int intResult = Int32.Parse(reader[1].ToString());
- }
- }
- #endregion
- }
- }
- #endregion
test
By: test | Date: Jan 12 2010 15:44 | Format: None | Expires: never | Size: 1.71 KB | Hits: 854
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago