DataGridView

L

Lewis

Hi,

I'm trying to use a DataGridView to display the contents of a SQL view.
At this point its easy. Where it gets complicated is that the view is
created on the fly by a stored procedure so the number of rows and
columns changes quite often because of data being entered into another
system elsewhere.

This isn't a problem until you check the number of columns in the
datagridview. When another column is added by the stored procedure the
datagridview chops off the last one in the view because its only got
definitions for the view before the extra column was added.

What i need to do is at run time reconnect the data table/data view to
the new structure of the SQL view. But i can't work it out.

Can anyone help me?

FYI there are currently 83 columns in the view, but when another was
added it chopped the 84th one off the end.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

How are you binding it? IIRC you can bind it to a datatable, which you get
as result of the query , something like:

DataAdapter da = new ....
da.selectcommand = command;
da.Fill ( ds ); //

my_grid.DataSource = ds.Tables[0];
my_grid.AutoGenerateColumns = true;
my_grid.Bind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top