Hi All,
Hope everyone had a white christmas. Well we had a white day after christmas, it is currently snowing here.
Anyway, I am trying to do a combobox that uses a dataview, Is it possible? It bombs my program and I get a really bizzare error.
My code:
' Create a new DataTable and set a DataColumn object as the primary key.
dsInfoServices.Tables.Add("ZipCode")
Dim keys(1) As DataColumn
Dim myColumn As DataColumn
' Create column 1 and add it to the array.
myColumn = New DataColumn
myColumn.DataType = System.Type.GetType("System.String")
myColumn.ColumnName = "ZipCode"
dsInfoServices.Tables("ZipCode").Columns.Add(myColumn)
' Add the column to the array.
keys(0) = myColumn
' Set the PrimaryKeys property to the array.
dsInfoServices.Tables("ZipCode").PrimaryKey = keys
sqlCmdInfoServices.CommandText = "spGetZipStateCities"
sqlAdapterInfoServices.Fill(dsInfoServices, "ZipCodes")
Dim dv As DataRowView
dv = dsInfoServices.Tables("ZipCodes").DefaultView.AddNew()
dv.DataView.RowFilter = "ZipCode Like '" & dsServices.Tables("Services").Rows(0).Item("Zip") & "%'"
Me.cmb_ServiceCity.DataSource = dv.DataView
Me.cmb_ServiceCity.DisplayMember = "City"
Me.cmb_ServiceCity.ValueMember = "City"
Basically the dsServices.Tables("Services").Rows(0).Item("Zip") comes fromt the main record. The cmb_servicecity is a list of cities within that zip code. They can either choose one or type on in themselves that is not in the list.
The error I am getting is so strange that I know it has nothing to do with the line iti s complaining about but mainly has something to do with the way I set up this combobox control.
Any ideas?
Hope everyone had a white christmas. Well we had a white day after christmas, it is currently snowing here.
Anyway, I am trying to do a combobox that uses a dataview, Is it possible? It bombs my program and I get a really bizzare error.
My code:
' Create a new DataTable and set a DataColumn object as the primary key.
dsInfoServices.Tables.Add("ZipCode")
Dim keys(1) As DataColumn
Dim myColumn As DataColumn
' Create column 1 and add it to the array.
myColumn = New DataColumn
myColumn.DataType = System.Type.GetType("System.String")
myColumn.ColumnName = "ZipCode"
dsInfoServices.Tables("ZipCode").Columns.Add(myColumn)
' Add the column to the array.
keys(0) = myColumn
' Set the PrimaryKeys property to the array.
dsInfoServices.Tables("ZipCode").PrimaryKey = keys
sqlCmdInfoServices.CommandText = "spGetZipStateCities"
sqlAdapterInfoServices.Fill(dsInfoServices, "ZipCodes")
Dim dv As DataRowView
dv = dsInfoServices.Tables("ZipCodes").DefaultView.AddNew()
dv.DataView.RowFilter = "ZipCode Like '" & dsServices.Tables("Services").Rows(0).Item("Zip") & "%'"
Me.cmb_ServiceCity.DataSource = dv.DataView
Me.cmb_ServiceCity.DisplayMember = "City"
Me.cmb_ServiceCity.ValueMember = "City"
Basically the dsServices.Tables("Services").Rows(0).Item("Zip") comes fromt the main record. The cmb_servicecity is a list of cities within that zip code. They can either choose one or type on in themselves that is not in the list.
The error I am getting is so strange that I know it has nothing to do with the line iti s complaining about but mainly has something to do with the way I set up this combobox control.
Any ideas?