Here I have a code which displays two columns from the table in a listbox.
Well, I think its unduely long for such a simple thing, I have followed the Black book to get this. Are all the steps are necessary for it? I mean the objects created -Code:Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim objConn As New OleDb.OleDbConnection() Dim objCommand As New OleDb.OleDbCommand() Dim objDataAdapter As New OleDb.OleDbDataAdapter() Dim objDataSet As New DataSet() Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & System.IO.Directory.GetCurrentDirectory.ToString & "\Db1.mdb" Dim strSelect As String = "Select * from members" objConn.ConnectionString = strConnectionString objConn.Open() objCommand.Connection = objConn objCommand.CommandText = strSelect objCommand.CommandType = CommandType.Text objDataAdapter.SelectCommand = objCommand objDataAdapter.Fill(objDataSet) Dim ctr As Short If objDataSet.Tables(0).Rows.Count > 0 Then For ctr = 0 To objDataSet.Tables(0).Rows.Count - 1 ListBox1.Items.Add(objDataSet.Tables(0).Rows(ctr).Item(0) & vbTab & _ objDataSet.Tables(0).Rows(ctr).Item(1)) Next End If objDataSet.Dispose() objDataSet = Nothing objCommand.Dispose() objCommand = Nothing objConn.Close() objConn = Nothing End Sub
connection object - needed
adapter onbject - I guess needed
Command object - ?
Dataset - ?
Well, I know There is a datareader - but would rather not get into it at the moment.
Well, also are app.path is not there hence - I have used that looooong thing - is there any other thing available for it?
Also i would like to know whether we have a EOF for the dataset like we used to have for are old recordsets?




Reply With Quote