I have several questions concerning the following setup:
I have A subroutine that dynamically attaches different tables to the same datagrid.
Assume all the tables selected have a key field.
My question concerns tables that have an
autoincrement Key field
Question 1: Does dataset reset empties the existing table schema? My fear is that I don't want the last table undisposed
Question 2: Do I have keep creating new commandbuilder object every time I switch tables? Or can I just re-use the old one by repointing it to the same dataAdapter again?
Question 3: As I said before, all tables have a key field. The ones with an autoincrement key field, where is that one populated? In the app or only when it gets to the back end? The reason I'm asking is because I dont' want the user to enter data into that field for obvious reasons.
I could write code that would indentify such fields and disable them... but how would the could indentify those fields?
Perhaps by use of the dataset.FillSchema method?
Thoughts?
- mongril
I have A subroutine that dynamically attaches different tables to the same datagrid.
Assume all the tables selected have a key field.
My question concerns tables that have an
autoincrement Key field
Code:
Dim ds as new DataSet, cmdSelect as New OleDBCommand
Dim da New OleDbDataAdapter
Dim cn as New OleDBConnection(CONNECTION_STR)
da.SelectCommand = CmdSelect
Private Sub TableAttach(byval tblName as String)
Dim cb as New OleDBCommandBuilder
ds.reset
With cmdSelect
.CommandText = "Select * from " & tblName
.Connection = cn
end With
cb.DataAdapter = da
da.Fill(ds, tblName)
dataGrid1.DataSource = ds.Table(0)
Question 1: Does dataset reset empties the existing table schema? My fear is that I don't want the last table undisposed
Question 2: Do I have keep creating new commandbuilder object every time I switch tables? Or can I just re-use the old one by repointing it to the same dataAdapter again?
Question 3: As I said before, all tables have a key field. The ones with an autoincrement key field, where is that one populated? In the app or only when it gets to the back end? The reason I'm asking is because I dont' want the user to enter data into that field for obvious reasons.
I could write code that would indentify such fields and disable them... but how would the could indentify those fields?
Perhaps by use of the dataset.FillSchema method?
Thoughts?
- mongril