2
Answers

Parametized Query--Filtering a Datagrid with combo box

Hi everyone

I'm still learning Csharp. And its langauge that I prefer to use to develop programs. I'm building a program that utilizes a datagrid control and a combobox. I use the combobox to filter the datagrid based on the region/city. I got this vb code, and its a bit old. And I want to re-write the code with csharp 2008. The coding style has really changed, no more things like 'generate dataset', and there are new things like 'bindingsource' . I have put the code extract that  I'm more concerned with, from the attached file:

Private Sub cboCountry_SelectedIndexChanged( _
 ByVal sender As System.Object, _
 ByVal e As System.EventArgs) _
 Handles cboCountry.SelectedIndexChanged

 ' Get the Parameter object and Set value
 With SqlDataAdapter1.SelectCommand.Parameters
 .Item("@CountryParam").Value = _
 cboCountry.SelectedValue
 End With

 ' Clear the dataset
 DsCustomers1.Clear()
 ' Load the dataset using the parameter value
 SqlDataAdapter1.Fill(DsCustomers1, "Customers")
End Sub


How do I do this? I've tried I get errors like 'missing directive'
Or do I have to re-write the entire project? How? I've put up the project, and its working except the combobox filtering part

Answers (2)