Re: How to re-populate a Data Grid?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Michael - if you aren't getting new rows from the database, you may want to
just use one of the datatable/dataview methods to filter your data. However
if you're freezing, then you need to look at what's happening there. First
check your sql command and make sure it's valid. Next make sure it's
returning and filling the datatable properly (make sure you don't have any
try/catch blocks that just eat the exception). Check the table to make sure
that you aren't filling on top of existing values (if you refilled a table
with no primary key or constraints, then the values woudl be appended at the
end and it would appear to not have changed, b/c the rows are down at the
bottom - even though the datatable has been refilled. If none of those are
it, let me know and we'll take it from there.

Cheers,

Bill
"Snake" <Snake@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:008860F6-6CCA-4597-9157-6E5917701C78@xxxxxxxxxxxxxxxx
>I have a vb .net program which fills a data grid upon form load from an
> acccess database. This works great. Now, I have to add a combo box and
> use
> it to alter the underlying sql statement and re-fill the data grid. I
> have
> never done this before, but I created a new sql statement in strSql from
> the
> combobox, update the data adapter, and try to fill the data grid. The
> program halts on the Fill with no particular explanation or complaint that
> I
> can determine. Something tells me that I have to do something else before
> the Fill from the dataset. Any suggestions?
>
> Thanks,
>
> Michael
>
>
> Private Sub cboContactPosition_SelectedIndexChanged _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles cboContactPosition.SelectedIndexChanged
>
> ' Define and build the SQL statement for the data grid . . .
>
>
> .
> .
> .
> daXtreme.SelectCommand.CommandText = strSql.ToString
>
> ' Fill the data grid using the new Sql command. . .
>
> Me.daXtreme.Fill(dsXtreme) ' Debug hangs here for
> some
> reason.
>
> End Sub
>


.