I'm working on my first VB .NET application. I feel I'm using datasets inneffeciently.
In form design I'm adding the connection, adapter, and dataset. This works great for populating controls on form load. However, if I want to populate controls during run time I find myself altering copied code from 'Windows Form Designer Generated Code' and modifying it accordingly. I first clear out the contents of the table(s) in the dataset and then alter the SQL string that I'm passing.
See example:
strSQL = "SELECT * FROM tbl_Sample WHERE ID = 1"
dsSample.tbl_Sample.Clear()
OleDbSelectCommand2.CommandText = strSQL
daSample.InsertCommand = OleDbSelectCommand2
OleDbSelectCommand2.Connection = ODBC
daSample.Fill(DsLoanStatus)
This works but I'm looking for a better way to handle this situation? Is there a way to initialize a new dataset, adapter, etc. during run time?
Thansk for you're help.
In form design I'm adding the connection, adapter, and dataset. This works great for populating controls on form load. However, if I want to populate controls during run time I find myself altering copied code from 'Windows Form Designer Generated Code' and modifying it accordingly. I first clear out the contents of the table(s) in the dataset and then alter the SQL string that I'm passing.
See example:
strSQL = "SELECT * FROM tbl_Sample WHERE ID = 1"
dsSample.tbl_Sample.Clear()
OleDbSelectCommand2.CommandText = strSQL
daSample.InsertCommand = OleDbSelectCommand2
OleDbSelectCommand2.Connection = ODBC
daSample.Fill(DsLoanStatus)
This works but I'm looking for a better way to handle this situation? Is there a way to initialize a new dataset, adapter, etc. during run time?
Thansk for you're help.