Jump to content

Display data from different queries in one gridcontrol

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
lemus

lemus

    Newbie

  • Members
  • Pip
  • 1 posts
Good afternoon everyone:

I am developing an application in C # with SQLServer2005. In one of the user controls that I use to display data from different queries in one gridcontrol. When I make the first query and update the datasourse loads fine but when I do the second one shows the number of columns for the first consultation.

What can I do to fix this problem?:confused:

#2
gaylo565

gaylo565

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 268 posts
This probably has to do with the scope of where your data scources are defined. I can't be sure though without seeing some code. I would put each of the queries into its own try block and define the data scource and update the datagridview within the try block so that the code will automatically do garbage collection at the end of the block but there are many different ways to make this work depending on your needs. You should simply be able to set the DataGridView.DataScource to a new table and it should update all of the needed properties. You may need to set the DataGridView.AutoGenerateColumns to true but I am not thinking that this is what is causing the problem.

P.S.--I just asumed you where using a datagridview....Which control are you using? There are different properties for the different ones so It makes it a bit hard to guess without knowing what you are using. If you could post a bit of the code it would help out tremendously;)