473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to re-populate a Data Grid?

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

Oct 18 '05 #1
3 4051
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" <Sn***@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
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

Oct 18 '05 #2
I added a try/Catch. I get "No value given for one or more required
parameters" from the Fill. I searched MSDN but to no avail yet. I can not
tell if the complaint is about the actual SQL code which looks fine and has
no parameters or something else. I keep thinking that some additional method
has to be executed prior to executing the second Fill. I will keep digging
.. . .

Michael
"W.G. Ryan - MVP" wrote:
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" <Sn***@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
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


Oct 18 '05 #3
Michael,

I am not sure of your combobox is inside or outside the datagrid.

Have a look at our website there is a lot about the datagrid.

http://www.vb-tips.com/default.aspx

I have a sample with a combobox outside the datagrid, however never placed
it because that it can be confusing.

If that is were you looking for than reply *here*

By the way, this questions are often done in the newsgroup
microsoft.public.dotnet.languages.vb

There is as well my fellow Ken active while he is that not here.
Probably have you more change on answers when using the VB.Net than here.

I hope this helps so far.

Cor


Oct 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Lothar Scholz | last post by:
Because PHP5 does not include the mysql extension any more is there a chance that we will see more Providers offering webspace with Firebird or Postgres Databases ? What is your opinion ? I must...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
2
by: sky2070 | last post by:
i have two file with jobapp.html calling jobapp_action.php <HTML> <!-- jobapp.html --> <BODY> <H1>Phop's Bicycles Job Application</H1> <P>Are you looking for an exciting career in the world of...
1
by: Clarice Almeida Hughes | last post by:
tenho um index onde tenho o link pro arq css, como sao visualizados pelo include todas as paginas aderem ao css linkado no index. so q eu preciso de alguns links com outras cores no css, o q devo...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.