Something like this to fill a dataset & Change the query selection depending
on the value of a dropdownlist
Dim sqlString As String = "SELECT * FROM People where person='" &
drpPeopleDropDown.SelectedValue & "';"
Dim sqlDA As New SqlClient.SqlDataAdapter
Dim sqlCommand As New SqlCommand(sqlString, sqlConnection)
Dim Peopl as New Dataset
sqlDA.SelectCommand = sqlCommand
Try
sqlConnection.Open()
sqlDA.Fill(People)
Catch ex As Exception
'TODO exception handling
Finally
sqlConnection.Close()
End Try
Then bind a DataGrid to the dataset
HTH
--
( OHM ) - One Handed Man
AKA Terry Burns -
http://TrainingOn.net [quoted text, click to view] <priyanka.freakout@gmail.com> wrote in message
news:1143961264.676129.222900@e56g2000cwe.googlegroups.com...
> Hi All,
>
> In my form I have created a dropdown box which is populated with data
> from a database on page load and i have also created a dropdwon box and
> what i intend on doing is displaying data re;ated to dropdown selection
> into a data grid.
>
> I have attached part of the code.
>
> Can someone please help me out on this cos i am really finding it
> difficult doing it with the data reader.
>
> Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DropDownList1.SelectedIndexChanged
>
> Dim str As String
> Dim sqlstr As String
> Dim ds As DataSet
> Dim ds1 As New DataSet
>
> Dim sqlcmd As New SqlClient.SqlCommand
> Dim dataadp As New SqlClient.SqlDataAdapter
>
> SqlConnection1.Open()
> str = DropDownList1.SelectedItem.Text
> Label1.Text = str
>
> sqlstr = "select * from Resources where Module_name=" + str
> Label3.Text = sqlstr
> sqlcmd = New SqlClient.SqlCommand(sqlstr, SqlConnection1)
> dataadp = New SqlClient.SqlDataAdapter(sqlcmd)
> dataadp.SelectCommand.Connection = SqlConnection1
> SqlCommand1.CommandText = sqlstr
> SqlCommand1.ExecuteReader()
>