DataGridView connected to SQLServer Express

N

netvisao

Hello!
I'm learning VB.Net


I have a DataGridView connected to SQLServer Express.

In explorer SQLServer Express if I try to change the column name or create a
new column, the column names in the DataGridView is not updated. What do I
have to update the name of the columns in the DataGridView?


Thanks
TC
 
M

Miro

I am assuming you added a "column" in the Database itself through SQLServer
Express.

Keep in mind that the "database" ( .mdf ) file is seperate from the vb.net
program.

So, you have step1 complete ( you have added the column ).

Assuming you are using the "built in drag drop features", when you dragged
the datagridview to your form, your project should have added a Dataset to
your project ( and then a copy of it on your form ).

In your solutions explorer / project explorer ( top right )...scrolL to the
dataset and double click on it.
-It should be a file with an .XSD extention.

You should see your "table(s)" there.
There are two sections to each table.
The first one is the "Fields", and the "Second" is the Table Adapter.

Right click on the "Fill,GetData()" table adapter of the table, and click on
"Configure".
This will allow you to get the new fields with the wizard.
-Test the query in the wizard to make sure you get your new field.

Now, once you have chagned your dataset here, you should be ok back in the
form and you should be able to add the field as well.

Cheers'

Miro
 
C

Cor Ligthert[MVP]

Are you automatically creating the columns or have you defined those by
yourself in the datagridview.

In the first situation, add columns (properties) to your class that is the
datasource in the other situation do the same, but also add columns to your
datagridview
 

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