I am using the following code instead of a very lengthly select case
statement.
(I have a lot of lookup tables in a settings form that are selected
from a ListBox. The data adapters are given a similar name to the
table. Rather than making a long Select Case that could become
obsolete if lookup tables are added and the source table of the
ListBox is edited I came up with this code.)
This code works but of course it gives me build errors.
Error:[Value of type 'String' cannot be converted to
'System.Data.Sq lClient.SqlData Adapter'.]
=== code snippit ===
Private Sub lstMasterLists_ Click(ByVal sender As Object, _
ByVal e As System.EventArg s) Handles lstMasterLists. Click
'To populate the dgMasterLists with the proper table
'1. use the returned TableName to make the DataAdapter name
'2. Convert the string to the DataAdampter type
'Get the TableName from the selected item in the list box
Dim strTbl As String
strTbl = Me.lstMasterLis ts.SelectedItem .ToString
'Make the DataAdapter name from the table name
Dim strDa As String
strDa = strTbl.Remove(0 , 5)
strDa = strDa.Insert(0, "Da")
CType(strDa, SqlDataAdapter) .fill(DsMasterL ists1, strTbl)
DgMasterLists.S etDataBinding(D sMasterLists1, strTbl)
End Sub
======
The code works in debug mode.
The exe works.
Does anyone anticipate me having any problems with this after
deployment?
Does anyone suggest any other alturnatives?
Does anyone suggest a way to stop the annoying build errors?
statement.
(I have a lot of lookup tables in a settings form that are selected
from a ListBox. The data adapters are given a similar name to the
table. Rather than making a long Select Case that could become
obsolete if lookup tables are added and the source table of the
ListBox is edited I came up with this code.)
This code works but of course it gives me build errors.
Error:[Value of type 'String' cannot be converted to
'System.Data.Sq lClient.SqlData Adapter'.]
=== code snippit ===
Private Sub lstMasterLists_ Click(ByVal sender As Object, _
ByVal e As System.EventArg s) Handles lstMasterLists. Click
'To populate the dgMasterLists with the proper table
'1. use the returned TableName to make the DataAdapter name
'2. Convert the string to the DataAdampter type
'Get the TableName from the selected item in the list box
Dim strTbl As String
strTbl = Me.lstMasterLis ts.SelectedItem .ToString
'Make the DataAdapter name from the table name
Dim strDa As String
strDa = strTbl.Remove(0 , 5)
strDa = strDa.Insert(0, "Da")
CType(strDa, SqlDataAdapter) .fill(DsMasterL ists1, strTbl)
DgMasterLists.S etDataBinding(D sMasterLists1, strTbl)
End Sub
======
The code works in debug mode.
The exe works.
Does anyone anticipate me having any problems with this after
deployment?
Does anyone suggest any other alturnatives?
Does anyone suggest a way to stop the annoying build errors?
Comment