مكونات الفئة System.Data :
تحتوي هذه الفئة على كل ما يخص قواعد البيانات والتعامل معها من دوال وخصائص وحتى رسائل الأخطاء exceptions ، سنستعرض هنا سريعاً أهم محتويات هذه الفئة حيث ستفيدنا في التعرف على خصائصها :
IDbConnection Interface :
منه يتم اشتقاق الفئة الخاصة بالاتصال بقاعدة البيانات ، يحتوي على الدوال التالية :
كود :
public interface IDbConnection : IDisposable
كود :
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]string ConnectionString { get; set; }[/FONT]
[FONT=Tahoma]int ConnectionTimeout { get; }[/FONT]
[FONT=Tahoma]string Database { get; }[/FONT]
[FONT=Tahoma]ConnectionState State { get; }[/FONT]
[FONT=Tahoma]IDbTransaction BeginTransaction();[/FONT]
[FONT=Tahoma]IDbTransaction BeginTransaction(IsolationLevel il);[/FONT]
[FONT=Tahoma]void ChangeDatabase(string databaseName);[/FONT]
[FONT=Tahoma]void Close();[/FONT]
[FONT=Tahoma]IDbCommand CreateCommand();[/FONT]
[FONT=Tahoma]void Open();[/FONT]
[FONT=Tahoma]}[/FONT]
IDbCommand Interface :
يتم منه اشتقاق الفئات الخاصة بالتعامل لاحقاً مع تنفيذ جمل الاستعلام ، يحتوي على الدوال التالية :
كود :
[FONT=Tahoma]public interface IDbCommand : IDisposable[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]string CommandText { get; set; }[/FONT]
[FONT=Tahoma]int CommandTimeout { get; set; }[/FONT]
[FONT=Tahoma]CommandType CommandType { get; set; }[/FONT]
[FONT=Tahoma]IDbConnection Connection { get; set; }[/FONT]
[FONT=Tahoma]IDataParameterCollection Parameters { get; }[/FONT]
[FONT=Tahoma]IDbTransaction Transaction { get; set; }[/FONT]
[FONT=Tahoma]UpdateRowSource UpdatedRowSource { get; set; }[/FONT]
[FONT=Tahoma]void Cancel();[/FONT]
[FONT=Tahoma]IDbDataParameter CreateParameter();[/FONT]
[FONT=Tahoma]int ExecuteNonQuery();[/FONT]
[FONT=Tahoma]IDataReader ExecuteReader();[/FONT]
[FONT=Tahoma]IDataReader ExecuteReader(CommandBehavior behavior);[/FONT]
[FONT=Tahoma]object ExecuteScalar();[/FONT]
[FONT=Tahoma]void Prepare();[/FONT]
[FONT=Tahoma]}[/FONT]
IDbDataParameter
تحتوي على :
كود :
[FONT=Tahoma]public interface IDbDataParameter : IDataParameter[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]byte Precision { get; set; }[/FONT]
[FONT=Tahoma]byte Scale { get; set; }[/FONT]
[FONT=Tahoma]int Size { get; set; }[/FONT]
[FONT=Tahoma]}[/FONT]
IDataParameter :
تحتوي على :
كود :
[FONT=Tahoma]public interface IDataParameter[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]DbType DbType { get; set; }[/FONT]
[FONT=Tahoma]ParameterDirection Direction { get; set; }[/FONT]
[FONT=Tahoma]bool IsNullable { get; }[/FONT]
[FONT=Tahoma]string ParameterName { get; set; }[/FONT]
[FONT=Tahoma]string SourceColumn { get; set; }[/FONT]
[FONT=Tahoma]DataRowVersion SourceVersion { get; set; }[/FONT]
[FONT=Tahoma]object Value { get; set; }[/FONT]
[FONT=Tahoma]}[/FONT]
IDbDataAdapter :
كود :
[FONT=Tahoma]public interface IDbDataAdapter : IDataAdapter[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]IDbCommand DeleteCommand { get; set; }[/FONT]
[FONT=Tahoma]IDbCommand InsertCommand { get; set; }[/FONT]
[FONT=Tahoma]IDbCommand SelectCommand { get; set; }[/FONT]
[FONT=Tahoma]IDbCommand UpdateCommand { get; set; }[/FONT]
[FONT=Tahoma]}[/FONT]
IDataAdapter :
كود :
[FONT=Tahoma]public interface IDataAdapter[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]MissingMappingAction MissingMappingAction { get; set; }[/FONT]
[FONT=Tahoma]MissingSchemaAction MissingSchemaAction { get; set; }[/FONT]
[FONT=Tahoma]ITableMappingCollection TableMappings { get; }[/FONT]
[FONT=Tahoma]int Fill(System.Data.DataSet dataSet);[/FONT]
[FONT=Tahoma]DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType);[/FONT]
[FONT=Tahoma]IDataParameter[] GetFillParameters();[/FONT]
[FONT=Tahoma]int Update(DataSet dataSet);[/FONT]
[FONT=Tahoma]}[/FONT]
IDataReader :
كود :
[FONT=Tahoma]public interface IDataReader : IDisposable, IDataRecord[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]int Depth { get; }[/FONT]
[FONT=Tahoma]bool IsClosed { get; }[/FONT]
[FONT=Tahoma]int RecordsAffected { get; }[/FONT]
[FONT=Tahoma]void Close();[/FONT]
[FONT=Tahoma]DataTable GetSchemaTable();[/FONT]
[FONT=Tahoma]bool NextResult();[/FONT]
[FONT=Tahoma]bool Read();[/FONT]
[FONT=Tahoma]}[/FONT]
IDataRecord :
كود :
[FONT=Tahoma]public interface IDataRecord[/FONT]
[FONT=Tahoma]{[/FONT]
[FONT=Tahoma]int FieldCount { get; }[/FONT]
[FONT=Tahoma]object this[ string name ] { get; }[/FONT]
[FONT=Tahoma]object this[ int i ] { get; }[/FONT]
[FONT=Tahoma]bool GetBoolean(int i);[/FONT]
[FONT=Tahoma]byte GetByte(int i);[/FONT]
[FONT=Tahoma]char GetChar(int i);[/FONT]
[FONT=Tahoma]DateTime GetDateTime(int i);[/FONT]
[FONT=Tahoma]Decimal GetDecimal(int i);[/FONT]
[FONT=Tahoma]float GetFloat(int i);[/FONT]
[FONT=Tahoma]short GetInt16(int i);[/FONT]
[FONT=Tahoma]int GetInt32(int i);[/FONT]
[FONT=Tahoma]long GetInt64(int i);[/FONT]
[FONT=Tahoma]...[/FONT]
[FONT=Tahoma]bool IsDBNull(int i);[/FONT]
[FONT=Tahoma]}[/FONT]
نكمل في الدرس القادم مع البدء باضافة قواعد بيانات إلى تطبيقاتنا ...