468,786 Members | 1,736 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,786 developers. It's quick & easy.

Generated code for DataGridView and Update

Hi,

I have a DataGridView that displays data from one table from database. I
didn’t implement any my code, I just used wizard to do all the work with
DatagridView populating.

Visual Studio generated strong typed dataset and binding. And here is my
problem.
I try to update the database with the new (changes) values from DataGridView:

Settings generated by Visual Studio:
dataGridView1.DataSource = tblMyTableBindingSource;

dataSetLKS.DataSetName = “DataSetLKS”

tblMyTableBindingSource.DataMember = “tblMyTable”;
tblMyTableBindingSource.DataSource = dataSetLKS;
private void button_Cllick(…)
{
this.tblMyTableAdapter.Update(this.MyDataSetName.T ables[0]);
}

I get error message “Update requires a valid UpdateCommand when passed
DataRow collection with modified rows.”

The one of auto generated Update methods is:

Public virtual int Update(DataSetLKS.tbl_StatusDataTable dataTable)
{
….
}

How should I correct the Update command?

Thanks,

Lubomir

Mar 28 '07 #1
3 2833
Does your table have a primary key, and is it included in the data
displayed?

Robin S.
-----------------------
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
Hi,

I have a DataGridView that displays data from one table from database. I
didn't implement any my code, I just used wizard to do all the work with
DatagridView populating.

Visual Studio generated strong typed dataset and binding. And here is my
problem.
I try to update the database with the new (changes) values from
DataGridView:

Settings generated by Visual Studio:
dataGridView1.DataSource = tblMyTableBindingSource;

dataSetLKS.DataSetName = "DataSetLKS"

tblMyTableBindingSource.DataMember = "tblMyTable";
tblMyTableBindingSource.DataSource = dataSetLKS;
private void button_Cllick(.)
{
this.tblMyTableAdapter.Update(this.MyDataSetName.T ables[0]);
}

I get error message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

The one of auto generated Update methods is:

Public virtual int Update(DataSetLKS.tbl_StatusDataTable dataTable)
{
..
}

How should I correct the Update command?

Thanks,

Lubomir

Mar 29 '07 #2
Yes, Ihave a primary key and I am displaying it.

Can it be a bug in generated code?
when I added the bindingSource control, set up its property and set the
datasource from grid to this control everything works fine.

But I can not get away with autogenerated code.

Thanks,

Lubomir

"RobinS" wrote:
Does your table have a primary key, and is it included in the data
displayed?

Robin S.
-----------------------
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
Hi,

I have a DataGridView that displays data from one table from database. I
didn't implement any my code, I just used wizard to do all the work with
DatagridView populating.

Visual Studio generated strong typed dataset and binding. And here is my
problem.
I try to update the database with the new (changes) values from
DataGridView:

Settings generated by Visual Studio:
dataGridView1.DataSource = tblMyTableBindingSource;

dataSetLKS.DataSetName = "DataSetLKS"

tblMyTableBindingSource.DataMember = "tblMyTable";
tblMyTableBindingSource.DataSource = dataSetLKS;
private void button_Cllick(.)
{
this.tblMyTableAdapter.Update(this.MyDataSetName.T ables[0]);
}

I get error message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

The one of auto generated Update methods is:

Public virtual int Update(DataSetLKS.tbl_StatusDataTable dataTable)
{
..
}

How should I correct the Update command?

Thanks,

Lubomir


Mar 29 '07 #3
What is the error message that you are getting? The Update Command doesn't
exist? Is it in the generated code? If you look at the properties in your
strongly typed dataset, does the Update SQL look right?

You're not joining two tables together, are you?

Robin S.
-------------------------------
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:D7**********************************@microsof t.com...
Yes, Ihave a primary key and I am displaying it.

Can it be a bug in generated code?
when I added the bindingSource control, set up its property and set the
datasource from grid to this control everything works fine.

But I can not get away with autogenerated code.

Thanks,

Lubomir

"RobinS" wrote:
>Does your table have a primary key, and is it included in the data
displayed?

Robin S.
-----------------------
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:86**********************************@microso ft.com...
Hi,

I have a DataGridView that displays data from one table from database.
I
didn't implement any my code, I just used wizard to do all the work
with
DatagridView populating.

Visual Studio generated strong typed dataset and binding. And here is
my
problem.
I try to update the database with the new (changes) values from
DataGridView:

Settings generated by Visual Studio:
dataGridView1.DataSource = tblMyTableBindingSource;

dataSetLKS.DataSetName = "DataSetLKS"

tblMyTableBindingSource.DataMember = "tblMyTable";
tblMyTableBindingSource.DataSource = dataSetLKS;
private void button_Cllick(.)
{
this.tblMyTableAdapter.Update(this.MyDataSetName.T ables[0]);
}

I get error message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."

The one of auto generated Update methods is:

Public virtual int Update(DataSetLKS.tbl_StatusDataTable dataTable)
{
..
}

How should I correct the Update command?

Thanks,

Lubomir



Mar 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by GS | last post: by
4 posts views Thread by Terry Olsen | last post: by
1 post views Thread by =?Utf-8?B?RGF0YUdyaWRWaWV3IGFkZCByb3cgZHluYW1pY2Fs | last post: by
6 posts views Thread by =?Utf-8?B?TU1TSkVE?= | last post: by
7 posts views Thread by Bill Schanks | last post: by
6 posts views Thread by =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.