Added Unique Contraint by my DataGridView doesn't seem to know about it...

G

Grant Schenck

Hello,

Win Forms .NET 2.0, Visual Studio 2008.

I wanted to prevent users from adding the same string for a Name column. I
modified my SQLServer DB and using Management Studio Express I checked and
sure enough it prevents me from putting data in the field.

Now I go back to a Winforms app I'm writing to work with the DB and the
DataGridView associated with my DataTable still allows me to put in
duplicate values. Only when I go to update it fail. So how to I get Visual
Studio to reload the table definitions to get the code in the designer to
reflect the new constraint?

Thanks!
 
G

Grant Schenck

That seems like an overkill. Are you saying anytime I want to change some
aspect of my database I need to delete it, remove it from my project and
then recreate it and add it back? That means I have to recreate the table
schema and save off and re-import existing data!

I would assume there is some way to tell Visual Studio to regenerate the
table definitions...
--
Grant Schenck


Miha Markic said:
Try removing the table from dataset and adding it again.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com

Grant Schenck said:
Hello,

Win Forms .NET 2.0, Visual Studio 2008.

I wanted to prevent users from adding the same string for a Name column.
I modified my SQLServer DB and using Management Studio Express I checked
and sure enough it prevents me from putting data in the field.

Now I go back to a Winforms app I'm writing to work with the DB and the
DataGridView associated with my DataTable still allows me to put in
duplicate values. Only when I go to update it fail. So how to I get
Visual Studio to reload the table definitions to get the code in the
designer to reflect the new constraint?

Thanks!
 
M

Miha Markic

Hi Grant,

Grant Schenck said:
That seems like an overkill. Are you saying anytime I want to change some
aspect of my database I need to delete it, remove it from my project and
then recreate it and add it back? That means I have to recreate the
table schema and save off and re-import existing data!

Not the database, the strong typed datasets. Open the dataset in the
designer, remove all tables (or all modified tables) and drag&drop them on
the dataset again.
I am assuming you have a strong typed datatable that is hosted within a
strong typed dataset?
If not, where/how do you get your DataTable from?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com
I would assume there is some way to tell Visual Studio to regenerate the
table definitions...
--
Grant Schenck


Miha Markic said:
Try removing the table from dataset and adding it again.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com

Grant Schenck said:
Hello,

Win Forms .NET 2.0, Visual Studio 2008.

I wanted to prevent users from adding the same string for a Name column.
I modified my SQLServer DB and using Management Studio Express I checked
and sure enough it prevents me from putting data in the field.

Now I go back to a Winforms app I'm writing to work with the DB and the
DataGridView associated with my DataTable still allows me to put in
duplicate values. Only when I go to update it fail. So how to I get
Visual Studio to reload the table definitions to get the code in the
designer to reflect the new constraint?

Thanks!
 
G

Grant Schenck

Got it! I'll give that a try.

Thanks to you both.

Regards,
--
Grant Schenck


Miha Markic said:
Hi Grant,

Grant Schenck said:
That seems like an overkill. Are you saying anytime I want to change
some aspect of my database I need to delete it, remove it from my project
and then recreate it and add it back? That means I have to recreate the
table schema and save off and re-import existing data!

Not the database, the strong typed datasets. Open the dataset in the
designer, remove all tables (or all modified tables) and drag&drop them on
the dataset again.
I am assuming you have a strong typed datatable that is hosted within a
strong typed dataset?
If not, where/how do you get your DataTable from?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com
I would assume there is some way to tell Visual Studio to regenerate the
table definitions...
--
Grant Schenck


Miha Markic said:
Try removing the table from dataset and adding it again.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com

Hello,

Win Forms .NET 2.0, Visual Studio 2008.

I wanted to prevent users from adding the same string for a Name
column. I modified my SQLServer DB and using Management Studio Express
I checked and sure enough it prevents me from putting data in the
field.

Now I go back to a Winforms app I'm writing to work with the DB and the
DataGridView associated with my DataTable still allows me to put in
duplicate values. Only when I go to update it fail. So how to I get
Visual Studio to reload the table definitions to get the code in the
designer to reflect the new constraint?

Thanks!
 

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