none
datagrid requery....

    Question

  • hi there!!! i have a problem regarding datagrid... how can i connect the datagrid to my database(code only)... and how can i requery the items in the datagrid using some condition thru combobox when i click the OK button... pls help....(express edition)
    Tuesday, January 16, 2007 12:20 AM

Answers

  • pinoyz,

     

    For the first question, connect the DataGrid to Database by code is as follows:

     

            Dim connection As New SqlConnection(ConnectionString)

            connection.Open()

            Dim adapter As New SqlDataAdapter(GetAllAuthorsSqlString, connection)

            Dim dataset As New DataSet

            adapter.Fill(dataset)

            adapter.Dispose()

            connection.Close()

            Dim table As DataTable = dataset.Tables(0)

            AddHandler table.ColumnChanged, New DataColumnChangeEventHandler(AddressOf ColumnChanged)

            datagridAuthors.DataSource = table

     

    Suppose you have the exact connection string and query command. When you use the ComboBox with the selection, it means changing the query condition, so just use the right SQL statement to make it suitable to your keywords.

     

    Monday, January 22, 2007 8:04 AM