Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataSet/Dataview/Combobox

Status
Not open for further replies.

LovinIt

Programmer
Dec 20, 2004
17
US
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top