Create a adapter without knowing the driver type
One of the great things with ADO.net is that you dont have to know which kind of connections/commands that you are using (interface based programming). You can use a connection to create a command, and command to create a reader.
IDbConnectin con = CreateConnection(_connectionString); //factory method
IDbCommand cmd = con.CreateCommand();
IDataReader reader = cmd.Execute开发者_如何学编程Reader();
But how do I create a IDataAdapter in the same way?
Public Overridable Function CreateDataAdapter() As System.Data.Common.DbDataAdapter
Member of System.Data.Common.DbProviderFactory
Summary:
Returns a new instance of the provider's class that implements the System.Data.Common.DbDataAdapter class.
Return Values:
A new instance of System.Data.Common.DbDataAdapter.
I have done what you are asking, but I cannot find the code. I will update answer when I can.
精彩评论