تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
What is DataAdapter?
#1
I will try to collect some info about

The subject source here
DataAdapter is a part of the ADO.NET Data Provider. DataAdapter provides the communication between the Dataset and the Datasource. We can use the DataAdapter in combination with the DataSet Object. That is these two objects combine to enable both data access and data manipulation capabilities.
The DataAdapter can perform Select , Insert , Update and Delete SQL operations in the Data Source. The Insert , Update and Delete SQL operations , we are using the continuation of the Select command perform by the DataAdapter. That is the DataAdapter uses the Select statements to fill a DataSet and use the other three SQL commands (Insert, Update, delete) to transmit changes back to the Database. From the following links describe how to use SqlDataAdapter and OleDbDataAdapter in detail.
SqlDataAdapter
OleDbDataAdapter.

What is SqlDataAdapter
SqlDataAdapter is a part of the ADO.NET Data Provider and it resides in the System.Data.SqlClient namespace. SqlDataAdapter provides the communication between the Dataset and the SQL database. We can use SqlDataAdapter Object in combination with Dataset Object.
Dim adapter As New SqlDataAdapter
The SqlDataAdapter Object and DataSet objects are combine to perform both data access and data manipulation operations in the SQL Server Database. When the user perform the SQL operations like Select , Insert etc. in the data containing in the Dataset Object , it won't directly affect the Database, until the user invoke the Update method in the SqlDataAdapter.

Download Source Code



What is OleDbDataAdapter
OleDbDataAdapter is a part of the ADO.NET Data Provider and it resides in the System.Data.OleDb namespace. OleDbDataAdapter provides the communication between the Dataset and the OleDb Data Sources. We can use OleDbDataAdapter Object in combination with Dataset Object.
The OleDbDataAdapter Object and DataSet objects are combine to perform both Data Access and Data Manipulation operations in the OleDb Data Sources. When the user perform the SQL operations like Select , Insert etc. in the data containing in the Dataset Object , it won't directly affect the Database, until the user invoke the Update method in the OleDbDataAdapter.

Download Source Code


Vb.NET ExecuteReader and ExecuteNonQuery
ExecuteReader : ExecuteReader used for getting the query results as a DataReader object. It is readonly forward only retrieval of records and it uses select command to read through the table from the first to the last.

 Dim reader As SqlDataReader
 reader = Command.ExecuteReader()
 While reader.Read()

   MsgBox(reader.Item(0))

 End While



 reader.Close()
ExecuteNonQuery : ExecuteNonQuery used for executing queries that does not return any data. It is used to execute the sql statements like update, insert, delete etc. ExecuteNonQuery executes the command and returns the number of rows affected.
 Dim retValue As Integer
 Command = New SqlCommand(Sql, Connection)


 retValue = Command.ExecuteNonQuery()

ADO.NET Connection Object
The Connection Object is a part of ADO.NET Data Provider and it is a unique session with the Data Source. In .Net Framework the Connection Object is Handling the part of physical communication between the application and the Data Source. Depends on the parameter specified in the Connection String ,ADO.NET Connection Object connect to the specified Database and open a connection between the application and the Database . When the connection is established , SQL Commands may be executed, with the help of the Connection Object, to retrieve or manipulate data in the Database. Once the Database activity is over , Connection should be closed and release the resources .
[صورة مرفقة: connection.JPG]
In ADO.NET the type of the Connection is depend on what Database system you are working with. The following are the commonly using the connections in the ADO.NET

ADO.NET SQL Server Connection

[صورة مرفقة: vb.png]

You can connect your VB.Net application to data in a SQL Server database using the Microsoft .NET Framework Data Provider for SQL Server. The first step in a VB.Net application is to create an instance of the Server object and to establish its connection to an instance of SQL Server.

[صورة مرفقة: star.png]

The SqlConnection Object is Handling the part of physical communication between the application and the SQL ServerDatabase. An instance of the SqlConnection class in .NET Framework is supported the Data Provider for SQL Server Database. The SqlConnection instance takes Connection String as argument and pass the value to the Constructor statement. When the connection is established , SQL Commands may be executed, with the help of the Connection Object, to retrieve or manipulate data in the database. Once the Database activities over , Connection should be closed and release the database resources .

Sql Server connection string


connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;


User ID=UserName;Password=Password"








If you have a named instance of SQL Server, you'll need to add that as well.


"Server=localhost\sqlexpress"








The Close() method in SqlConnection class is used to close the Database Connection. The Close method rolls back any pending transactions and releases the Connection from the SQL Server Database.

A Sample VB.Net Program that connect SQL Server using connection string.



Imports System.Data.SqlClient

Public Class Form1

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       Dim connetionString As String

       Dim cnn As SqlConnection

       connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"

       cnn = New SqlConnection(connetionString)

       Try

           cnn.Open()

           MsgBox("Connection Open ! ")

           cnn.Close()

       Catch ex As Exception

           MsgBox("Can not open connection ! ")

       End Try

   End Sub

End Class

----------------------------


ADO.NET OLEDB Connection
An instance of the OleDbConnection class in .NET Framework is supported the OLEDB Data Provider. The OleDbConnection instance takes Connection String as argument and pass the value to the Constructor statement. When the connection is established , SQL Commands may be executed, with the help of the Connection Object, to retrieve or manipulate data in the database.
Once the Database activities over , Connection should be closed and release the resources . The Close() method in SqlConnection class is used to close the Database Connection. The Close method rolls back any pending transactions and releases the Connection from the Database connected by the OLEDB Data Provider.

[b]Download Source Code[/b]


ADO.NET ODBC Connection
An instance of the OdbcConnection class in .NET Framework is supported the ODBC Data Provider. The OdbcConnection instance takes Connection String as argument and pass the value to the Constructor statement. When the connection is established , SQL Commands may be executed, with the help of the Connection Object, to retrieve or manipulate data in the database.
Once the Database activities over , Connection should be closed and release the resources . The Close() method in SqlConnection class is used to close the Database Connection. The Close method rolls back any pending transactions and releases the Connection from the Database connected by the ODBC Data Provider.

[b]Download Source Code[/b]


You have to provide the necessary informations to the Connection String. 
[b]connetionString = "Driver = {Microsoft Access Driver (*.mdb)}; DBQ = yourdatabasename.mdb;" [/b]
From the above statement replace yourdatabasename.mdb to the actual names.

ADO.NET Command
The Command Object in ADO.NET executes SQL statements and Stored Procedures against the data source specified in the Connection Object. The Command Object required an instance of a Connection Object for executing the SQL statements. That is, for retrieving data or execute an SQL statement against a Data Source , you have to create a Connection Object and open a connection to the Data Source, and assign the open connection to the connection property of the Command Object. When the Command Object return result set , a Data Reader is used to retrieve the result set.
[صورة مرفقة: command.JPG]
The Command Object has a property called CommandText, which contains a String value that represents the command that will be executed in the Data Source. When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure.
Click the following links to see some important built in methods uses in the Command Object to execute the SQL statements.



=Google Translation for who doesn't know english as well =



DataAdapter وجزء من مقدم ADO.NET البيانات. يوفر DataAdapter والتواصل بين مجموعات البيانات ومصدر البيانات. يمكننا استخدام DataAdapter وبالاشتراك مع الكائن DataSet. هذا هو هذه الكائنين تتضافر لتمكين كل من الوصول إلى البيانات ومعالجة البيانات القدرات.
وDataAdapter ويمكن أن تؤدي حدد، إدراج وتحديث وحذف عمليات SQL في مصدر البيانات. عمليات SQL إدراج وتحديث وحذف، ونحن يستخدمون استمرار اختر أمر أداء من قبل DataAdapter و. هذا هو يستخدم DataAdapter والتحديد تصريحات لتعبئة DataSet واستخدام الأوامر SQL الثلاثة الأخرى (إدراج، تحديث، حذف) لنقل التغييرات إلى قاعدة البيانات. من خلال الروابط التالية تصف كيفية استخدام SqlDataAdapter وOleDbDataAdapter في التفاصيل.
SqlDataAdapter
OleDbDataAdapter.
ما هو SqlDataAdapter
SqlDataAdapter هو جزء من موفر ADO.NET بيانات ويقيم في مساحة الاسم System.Data.SqlClient. يوفر SqlDataAdapter التواصل بين الكتالوج وقاعدة بيانات SQL. يمكننا استخدام كائن SqlDataAdapter في تركيبة مع الكائن DataSet.
محول قاتمة كما جديد SqlDataAdapter
الكائنات كائن SqlDataAdapter ومجموعة البيانات يتم الجمع بين لأداء كل الوصول إلى البيانات ومعالجة البيانات العمليات في قاعدة بيانات خادم SQL. عندما يقوم المستخدم بإجراء عمليات SQL مثل تحديد، أدخل وما إلى ذلك في البيانات التي تحتوي في الكائن DataSet، فإنه لن تؤثر بشكل مباشر على قاعدة البيانات، حتى المستخدم استدعاء أسلوب التحديث في SqlDataAdapter.
تحميل شفرة المصدر

ما هو OleDbDataAdapter
OleDbDataAdapter هو جزء من موفر ADO.NET بيانات ويقيم في مساحة الاسم System.Data.OleDb. يوفر OleDbDataAdapter التواصل بين الكتالوج ومصادر البيانات OLEDB. يمكننا استخدام كائن OleDbDataAdapter في تركيبة مع الكائن DataSet.
الكائنات كائن OleDbDataAdapter ومجموعة البيانات يتم الجمع بين لأداء كل الوصول إلى البيانات وعمليات معالجة البيانات في مصادر البيانات OLEDB. عندما يقوم المستخدم بإجراء عمليات SQL مثل تحديد، أدخل وما إلى ذلك في البيانات التي تحتوي في الكائن DataSet، فإنه لن تؤثر بشكل مباشر على قاعدة البيانات، حتى المستخدم استدعاء أسلوب التحديث في في OleDbDataAdapter.
تحميل شفرة المصدر
Vb.NET اكسيكوتيريدير وExecuteNonQuery
اكسيكوتيريدير: اكسيكوتيريدير استخدامها للحصول على نتائج الاستعلام باعتباره كائن DataReader. هو للقراءة فقط استرجاع الأمام الوحيد السجلات وأنه يستخدم حدد الأمر من خلال قراءة الجدول من البداية حتى النهاية.

 القارئ قاتمة كما SqlDataReader
 القارئ = Command.ExecuteReader ()
 في حين reader.Read ()
   MsgBox (reader.Item (0))
 وفي حين نهاية

 reader.Close ()
ExecuteNonQuery: ExecuteNonQuery المستخدمة لتنفيذ الاستعلامات التي لا يقوم بإرجاع أية بيانات. يتم استخدامه لتنفيذ عبارات SQL مثل التحديث، إدراج، حذف الخ ExecuteNonQuery ينفذ الأمر وإرجاع عدد الصفوف المتأثرة.
 خافت retValue وصحيح
 الأمر = جديد تعيين SqlCommand (SQL، اتصال)

 retValue = Command.ExecuteNonQuery ()
ADO.NET كائن اتصال
كائن اتصال هو جزء من مزود ADO.NET البيانات وأنها دورة فريدة من نوعها مع مصدر البيانات. في إطار صافي كائن الاتصال والتعامل مع جزء من التواصل الجسدي بين التطبيق ومصدر البيانات. يعتمد على المعلمة المحددة في سلسلة الاتصال، ADO.NET كائن اتصال الاتصال بقاعدة بيانات محددة، وفتح اتصال بين التطبيق وقاعدة البيانات. عندما يتم تأسيس الاتصال، أوامر SQL قد يتم تنفيذها، مع مساعدة من كائن اتصال، لاسترداد أو التعامل مع البيانات في قاعدة البيانات. وبمجرد أن النشاط قاعدة البيانات قد انتهت، ويجب أن تكون مغلقة اتصال والافراج عن الموارد.

في ADO.NET نوع من اتصال وتعتمد على ما هو نظام قاعدة البيانات الذي تعمل به. وفيما يلي عادة باستخدام الاتصالات في ADO.NET
ADO.NET اتصال ملقم SQL

يمكنك الاتصال تطبيق VB.Net لالبيانات في قاعدة بيانات SQL Server باستخدام موفر بيانات Microsoft .NET Framework ل SQL Server. الخطوة الأولى في تطبيق VB.Net هو خلق مثيل كائن الملقم وتأسيس اتصال إلى مثيل من SQL Server.

الكائن SqlConnection هو التعامل مع الجزء من التواصل الجسدي بين الطلب وServerDatabase SQL. ويدعم مثيل من فئة SqlConnection في إطار عمل. NET موفر البيانات لقاعدة بيانات خادم SQL. على سبيل المثال SqlConnection يأخذ سلسلة اتصال كوسيطة وتمرير القيمة إلى بيان منشئ. عندما يتم تأسيس الاتصال، أوامر SQL قد يتم تنفيذها، مع مساعدة من كائن اتصال، لاسترداد أو التعامل مع البيانات في قاعدة البيانات. وبمجرد أن أنشطة قاعدة البيانات أكثر، يجب أن تكون مغلقة اتصال والافراج عن موارد قاعدة البيانات.
سلسلة اتصال SQL Server

connetionString = "مصدر البيانات = الخادم؛ كتالوج الأولية = و databasename؛
معرف المستخدم = اسم المستخدم، كلمة المرور = كلمة السر "



إذا كان لديك مثيل SQL Server مسماة، سوف تحتاج إلى إضافة ذلك أيضا.

"خادم = المضيف المحلي \ SQLEXPRESS"



يتم استخدام الأسلوب إغلاق () في فئة SqlConnection لإغلاق اتصال قاعدة البيانات. أسلوب إغلاق تتحرك مرة أخرى أية معاملات العالقة والنشرات اتصال من قاعدة بيانات خادم SQL.
نموذج برنامج VB.Net التي تربط SQL Server باستخدام سلسلة الاتصال.

واردات System.Data.SqlClient
Form1 فئة الجمهور
   خاص الفرعية Button1_Click (الأساسية ByVal المرسل وSystem.Object، الأساسية ByVal ه وSystem.EventArgs) مقابض Button1.Click
       خافت connetionString كسلسلة
       خافت CNN كما SqlConnection
       connetionString = "مصدر البيانات = الخادم؛ كتالوج الأولية = و databasename؛ معرف المستخدم = اسم المستخدم، كلمة المرور = كلمة السر"
       CNN = SqlConnection جديد (connetionString)
       محاولة
           cnn.Open ()
           MsgBox ("اتصال مفتوح!")
           cnn.Close ()
       الصيد السابق واستثناء
           MsgBox ("لا يمكن فتح اتصال!")
       نهاية المحاولة
   نهاية الفرعية
نهاية الدرجة
----------------------------
اتصال OLEDB ADO.NET
ويدعم مثيل من فئة OleDbConnection في إطار عمل. NET موفر OLEDB البيانات. على سبيل المثال OleDbConnection يأخذ سلسلة اتصال كوسيطة وتمرير القيمة إلى بيان منشئ. عندما يتم تأسيس الاتصال، أوامر SQL قد يتم تنفيذها، مع مساعدة من كائن اتصال، لاسترداد أو التعامل مع البيانات في قاعدة البيانات.
وبمجرد أن أنشطة قاعدة البيانات أكثر، يجب أن تكون مغلقة اتصال والافراج عن الموارد. يتم استخدام الأسلوب إغلاق () في فئة SqlConnection لإغلاق اتصال قاعدة البيانات. أسلوب إغلاق تتحرك مرة أخرى أية معاملات العالقة والنشرات اتصال من قاعدة بيانات متصلة بواسطة موفر OLEDB البيانات.
تحميل شفرة المصدر
اتصال ADO.NET ODBC
ويدعم مثيل من فئة OdbcConnection في إطار عمل. NET موفر البيانات ODBC. على سبيل المثال OdbcConnection يأخذ سلسلة اتصال كوسيطة وتمرير القيمة إلى بيان منشئ. عندما يتم تأسيس الاتصال، أوامر SQL قد يتم تنفيذها، مع مساعدة من كائن اتصال، لاسترداد أو التعامل مع البيانات في قاعدة البيانات.
وبمجرد أن أنشطة قاعدة البيانات أكثر، يجب أن تكون مغلقة اتصال والافراج عن الموارد. يتم استخدام الأسلوب إغلاق () في فئة SqlConnection لإغلاق اتصال قاعدة البيانات. أسلوب إغلاق تتحرك مرة أخرى أية معاملات العالقة والنشرات اتصال من قاعدة بيانات متصلة بواسطة موفر البيانات ODBC.
تحميل شفرة المصدر
لديك لتوفير المعلومات اللازمة لسلسلة الاتصال.
connetionString = "سائق = {مايكروسوفت أكسس سائق (* .MDB)}؛ DBQ = yourdatabasename.mdb."
من العبارة أعلاه استبدال yourdatabasename.mdb في الأسماء الفعلية.
ADO.NET القيادة
كائن الأمر في ADO.NET ينفذ البيانات SQL والإجراءات المخزنة على مصدر البيانات المحددة في كائن اتصال. كائن الأمر يتطلب مثيل كائن اتصال لتنفيذ البيانات SQL. وهذا هو، لاسترجاع البيانات أو تنفيذ عبارة SQL ضد مصدر بيانات، لديك لإنشاء كائن اتصال وفتح اتصال إلى مصدر البيانات، وتعيين اتصال مفتوح إلى خاصية اتصال من كائن الأوامر. عندما القيادة عودة كائن نتيجة مجموعة، يتم استخدام قارئ البيانات لاسترداد مجموعة النتائج.

كائن الأوامر له خاصية تسمى CommandText، والتي تحتوي على قيمة سلسلة تمثل الأمر الذي سيتم تنفيذه في مصدر البيانات. عندما تم تعيين الخاصية CommandType لStoredProcedure، يجب تعيين الخاصية CommandText إلى اسم الإجراء المخزن.
النقر على الروابط التالية لمعرفة بعض الأهمية التي بنيت في الأساليب التي تستخدمها في كائن الأوامر لتنفيذ جمل SQL.


** طبعا هذه المعلومات لمن هو مبتديء بللكلية في الدوت نت 
ان شاء الله سنجد كلاسات تسهل على المستخدم الاتصال والتعامل مع قواعد البيانات والجداول بشكل سهل 
وسلس للكل
بالتوفيق
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
 اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات
الرد }}}
تم الشكر بواسطة: الشاكي لله
#2
يعطيك العافية  ...

 سؤال : أنت سمعت عن العصر الحجري يا أبو عمر ...؟

تعــــــــــال هنــــــــــــا عايز أحكي معاك  ..
Abu Ehab : Microsoft Partner  & Systems Developer
 Youtube   Facebook    Twitter   
الرد }}}
تم الشكر بواسطة: الشاكي لله
#3
ويعطيك الف عافية
وانا اخوك لازلت اعيش فيه
ماشي الحال جاي لك!
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
 اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات
الرد }}}
تم الشكر بواسطة: الشاكي لله


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم