#1
http://www.learnasp.com/freebook/learn/index.aspx?caller=utilitybelt§ion=Databases
the first 6 lessons show you exactly that.
#2 Common Sin:
Using Datasets to fill because the the Micrososft Quickstarts Docs do (mostly because they were written in Beta1 before ExecuteReader existed) , i.e.
Dim DS As DataSet
Dim MyConnection As OLEDBConnection
Dim MyCommand As OLEDBDataAdapter
MyConnection = New OLEDBConnection("....")
MyCommand = New OLEDBDataAdapter("select * from publishers where
state='NY'", MyConnection)
DS = new DataSet()
MyCommand.Fill(ds, "NYStateOfMind")
MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
MyDataGrid.DataBind()
MYConnection.Close()
when a
=> Executereader does the job much much much faster <=
without all the overhead of dataset object and with less code:
Dim MyConnection As new OLEDBConnection("....")
Dim MyCommand As OLEDBCommand("select * from publishers where state='NY'")
DIM myreader as new
OLEBDBReader()=MyCommand.ExecuteReader(system.data.commandbehavior.closeconnection)
MyDataGrid.DataSource=myreader
MyDataGrid.DataBind()
myReader.Close()