Description:
When doing a fill adapter in VB 2008 with connector/Net 5.2 (see routine below)
Without the FillSchema i cannot get the maxlenght set properly in the column attributes of the datatable for string etc.. Populating unknown MySQL tables is needed for certain types of operations. Note: this creates another problem which will be placed in a another bug report.
Public Function GetDGData(ByVal sDB As String, ByVal selectCommand As String) As DataTable
Try
Call ClearErrors("Get DG Data")
' Create a connection string
If sDB = "GENSYS" Then
Call MyConnectString("GENSYS", True)
Else
Call MyConnectString(gGeneral.DataDB, True)
End If
' Create a new data adapter based on the specified query.
MyDGdaAdapter = New MySqlDataAdapter(selectCommand, MyDGConnString)
' Create a command builder to generate SQL update, insert, and
' delete commands based on selectCommand. These are used to
' update the database.
MyDGCmdBuilder = New MySqlCommandBuilder(MyDGdaAdapter)
' Populate a new data table and bind it to the BindingSource.
MyDGdtDataTable = New DataTable()
MyDGDataset = New DataSet()
MyDGdaAdapter.FillSchema(MyDGDataset, SchemaType.Mapped)
' Without above statement cannot get proper length for string fields
MyDGdaAdapter.Fill(MyDGDataset)
Return (MyDGDataset.Tables(0))
Catch eX As MySqlException
Call SetMySQLErrors(eX, "Get Data - MySql-DataGridView")
End Try
Return (Nothing)
How to repeat:
See above function in description
Suggested fix:
Automatically fill in all schema attribules especially field sizes
Description: When doing a fill adapter in VB 2008 with connector/Net 5.2 (see routine below) Without the FillSchema i cannot get the maxlenght set properly in the column attributes of the datatable for string etc.. Populating unknown MySQL tables is needed for certain types of operations. Note: this creates another problem which will be placed in a another bug report. Public Function GetDGData(ByVal sDB As String, ByVal selectCommand As String) As DataTable Try Call ClearErrors("Get DG Data") ' Create a connection string If sDB = "GENSYS" Then Call MyConnectString("GENSYS", True) Else Call MyConnectString(gGeneral.DataDB, True) End If ' Create a new data adapter based on the specified query. MyDGdaAdapter = New MySqlDataAdapter(selectCommand, MyDGConnString) ' Create a command builder to generate SQL update, insert, and ' delete commands based on selectCommand. These are used to ' update the database. MyDGCmdBuilder = New MySqlCommandBuilder(MyDGdaAdapter) ' Populate a new data table and bind it to the BindingSource. MyDGdtDataTable = New DataTable() MyDGDataset = New DataSet() MyDGdaAdapter.FillSchema(MyDGDataset, SchemaType.Mapped) ' Without above statement cannot get proper length for string fields MyDGdaAdapter.Fill(MyDGDataset) Return (MyDGDataset.Tables(0)) Catch eX As MySqlException Call SetMySQLErrors(eX, "Get Data - MySql-DataGridView") End Try Return (Nothing) How to repeat: See above function in description Suggested fix: Automatically fill in all schema attribules especially field sizes