i can retrieve the data from the DB and put it in a vector and then , vector in a JTable, to display data in a tabular format in java,
all i wanted to know is there any similar way in vb dotnet?
Printable View
i can retrieve the data from the DB and put it in a vector and then , vector in a JTable, to display data in a tabular format in java,
all i wanted to know is there any similar way in vb dotnet?
I think what you're looking for is a datagridview. If you added a datasource to your project, simply drag it to your form. Otherwise, there is a datagridview in your toolbar(Toolbar -> Data -> DataGridView); and from there use a SQL select stament to populate it.
A little fyi, if you take the first route, there is an sql statement. It's just generated when you add the datasource to your project and the command that populates the dgv is in your form_load event and it's tableadapter.fill().
If I misunderstood you, please let me know.
A suggestion, do not assume those reading this question have a clue to what a JTable is in Java, some may while other may not. Best to provide a simple image showing what you are after or a link explaining a JTable.
http://www.java2s.com/Code/JavaImages/TableFeature.PNG
If you want to take route number 2, you need to add the DataGridView to your form and add a select statement to populate the datagridview. This can be done in a few ways, the most common is in your Form_Load event or in a button_click event. The way to explain your select statement is like such:
The select * is saying that you want to select all recordsCode:Select * From myDataTable
The from mydatatable is the Table Name you want to select it from.
Try this out:
Code:'Set up our connection
Dim connetionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\PC #6\My Documents\db2.mdb;"
Dim connection As OleDbConnection
connection = New OleDbConnection(connetionString)
Try
'Open it up
connection.Open()
'SQL Select Command
'To filter, add a Where Clause
Dim sql As String = "Select * From customers"
'Set up a DataAdapter
Dim adapter As New OleDbDataAdapter(sql, connection)
'And a Table
Dim dt As New DataTable("customers")
'Now fill the adapter with the datatable
adapter.Fill(dt)
'Populate the DGV
DataGridView1.DataSource = dt
'Please close it when you're done.
connection.Close()
Catch ex As Exception
'If by any chance you get a message box with an error
'It's generally because you mispelt your conString or Datatable
MsgBox(ex.ToString)
End Try