I have different books that I am using to play with ASP.NET and one talks about the DataAdapter, dbCommandBuilder and DataSet object - but doesn't mention the DataReader object. The other book talks and uses the DataReader object and doesn't mention the other 3.
Why is this? Are they the same, just different ways of accomplishing the same thing? Does it matter which you use?
For example the following 2 sets of code, apparently accomplish the same thing. It seems to be easier to use the DataReader style. But if the other style gives you something better than the DataReader, you might want to use the other.
Why is this? Are they the same, just different ways of accomplishing the same thing? Does it matter which you use?
For example the following 2 sets of code, apparently accomplish the same thing. It seems to be easier to use the DataReader style. But if the other style gives you something better than the DataReader, you might want to use the other.
Code:
Dim ConnectString, SelectStatement As String
Dim Connect As OleDbConnection = New OleDbConnection
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter
Dim ClassyCB As OleDbCommandBuilder
Dim ClassyDS As DataSet = New DataSet
Dim Row As DataRow
SelectStatement = "Select * From Ads Where AdNum=" & _
AdNumSent
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\inetpub\[URL unfurl="true"]wwwroot\simplyClassy\classydb.mdb"[/URL]
Connect.ConnectionString = ConnectString
Adapter.SelectCommand = _
new OleDbCommand(SelectStatement, Connect)
' ClassyCB = New OleDbCommandBuilder(Adapter)
Adapter.SelectCommand.Connection.Open
Adapter.Fill(ClassyDS,"Ads")
Row = ClassyDS.Tables("Ads").Rows(0)
TitleText.Text = Row.Item("Title")
Code:
Dim ConnectString, SelectStatement As String
Dim Connect As OleDbConnection = New OleDbConnection
Dim dbCommand As OleDBCommand
SelectStatement = "Select * From Ads Where AdNum=" & _
AdNumSent
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\inetpub\[URL unfurl="true"]wwwroot\simplyClassy\classydb.mdb"[/URL]
Connect.ConnectionString = ConnectString
dbCommand = New OleDbCommand(SelectStatement)
dataResponse = dbCommand.ExecuteReader()
TitleText.Text = dataResponse("Title")