Dataview, adding a row

G

Guest

trying to add a new row by entering it directly in datagrid bound to dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the same time this datarow is being created through Dataview?
 
G

Guest

also, if i get a new row to be accepted, on update it replicates the row and appends to list.
 
M

Miha Markic [MVP C#]

Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
trying to add a new row by entering it directly in datagrid bound to dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
G

Guest

yes, i had just realized it was filtering before i could enter the new filter column value and therefore 'disappearing'.

the real problem now seems to be that when the new row is Updated, the new primary keys created by the database result in additional rows(duplicates) in the DataSet and thus the Datagrid. Would calling the Datable.Clear() before the Fill method be considered poor practice? Or is it better to use RowUpdated to find the new primary keys and then change the old values?

thanks.


Miha Markic said:
Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
trying to add a new row by entering it directly in datagrid bound to dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
M

Miha Markic [MVP C#]

Hi,

How are you doing updates?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
yes, i had just realized it was filtering before i could enter the new
filter column value and therefore 'disappearing'.
the real problem now seems to be that when the new row is Updated, the new
primary keys created by the database result in additional rows(duplicates)
in the DataSet and thus the Datagrid. Would calling the Datable.Clear()
before the Fill method be considered poor practice? Or is it better to use
RowUpdated to find the new primary keys and then change the old values?
thanks.


Miha Markic said:
Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
trying to add a new row by entering it directly in datagrid bound to dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
G

Guest

datatable autogenerates PK (-1 seed, -1 increment). then Access database assigns autonumber for these rows. several tables are updated at the same time.

da.Update(dataSet1, "tblName1");
da.Update(dataSet1, "tblName2");
etc...
da.Fill(dataSet1.tblName1);
da.Fill(dataSet1.tblName2);
etc..

WHen the dataTables are filled, the rows with PKs originally generated by dataset stay in DataView, and new rows added with Access generated PKs are added on resulting isn duplicated rows. Using datatable.clear solves problem but seems sloppy. if i use RowUpdated i suppose i could acheive the same?





Miha Markic said:
Hi,

How are you doing updates?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
yes, i had just realized it was filtering before i could enter the new
filter column value and therefore 'disappearing'.
the real problem now seems to be that when the new row is Updated, the new
primary keys created by the database result in additional rows(duplicates)
in the DataSet and thus the Datagrid. Would calling the Datable.Clear()
before the Fill method be considered poor practice? Or is it better to use
RowUpdated to find the new primary keys and then change the old values?
thanks.


Miha Markic said:
Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

trying to add a new row by entering it directly in datagrid bound to
dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
C

chen qi

1.In DB: write a stored-procedure, mark the @pk with 'out'
--example:
create procedure insertRow
@pk int = null out
.......
as
.......

2.In VS: add parameters of da.UpdateCommand

3.mark the "@pk" parameter direction as "out", and bind it's to
{table_pk_column}

now everytime after u ececuted the update(), the table can get PK value
automatically.
ps: there's some spelling error above, -_-b

subT said:
datatable autogenerates PK (-1 seed, -1 increment). then Access database
assigns autonumber for these rows. several tables are updated at the same
time.
da.Update(dataSet1, "tblName1");
da.Update(dataSet1, "tblName2");
etc...
da.Fill(dataSet1.tblName1);
da.Fill(dataSet1.tblName2);
etc..

WHen the dataTables are filled, the rows with PKs originally generated by
dataset stay in DataView, and new rows added with Access generated PKs are
added on resulting isn duplicated rows. Using datatable.clear solves problem
but seems sloppy. if i use RowUpdated i suppose i could acheive the same?
Miha Markic said:
Hi,

How are you doing updates?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
yes, i had just realized it was filtering before i could enter the new
filter column value and therefore 'disappearing'.
the real problem now seems to be that when the new row is Updated, the
new
primary keys created by the database result in additional rows(duplicates)
in the DataSet and thus the Datagrid. Would calling the Datable.Clear()
before the Fill method be considered poor practice? Or is it better to use
RowUpdated to find the new primary keys and then change the old values?
thanks.


:

Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

trying to add a new row by entering it directly in datagrid bound to
dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
M

Miha Markic [MVP C#]

Hi,

Read this article:
HOW TO: Retrieve the Identity Value While Inserting Records into Access
Database By Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;816112&Product=adonet

Does it help?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
datatable autogenerates PK (-1 seed, -1 increment). then Access database
assigns autonumber for these rows. several tables are updated at the same
time.
da.Update(dataSet1, "tblName1");
da.Update(dataSet1, "tblName2");
etc...
da.Fill(dataSet1.tblName1);
da.Fill(dataSet1.tblName2);
etc..

WHen the dataTables are filled, the rows with PKs originally generated by
dataset stay in DataView, and new rows added with Access generated PKs are
added on resulting isn duplicated rows. Using datatable.clear solves problem
but seems sloppy. if i use RowUpdated i suppose i could acheive the same?
Miha Markic said:
Hi,

How are you doing updates?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
yes, i had just realized it was filtering before i could enter the new
filter column value and therefore 'disappearing'.
the real problem now seems to be that when the new row is Updated, the
new
primary keys created by the database result in additional rows(duplicates)
in the DataSet and thus the Datagrid. Would calling the Datable.Clear()
before the Fill method be considered poor practice? Or is it better to use
RowUpdated to find the new primary keys and then change the old values?
thanks.


:

Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

trying to add a new row by entering it directly in datagrid bound to
dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 
G

Guest

yes that will.. thanks.


Miha Markic said:
Hi,

Read this article:
HOW TO: Retrieve the Identity Value While Inserting Records into Access
Database By Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;816112&Product=adonet

Does it help?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

subT said:
datatable autogenerates PK (-1 seed, -1 increment). then Access database
assigns autonumber for these rows. several tables are updated at the same
time.
da.Update(dataSet1, "tblName1");
da.Update(dataSet1, "tblName2");
etc...
da.Fill(dataSet1.tblName1);
da.Fill(dataSet1.tblName2);
etc..

WHen the dataTables are filled, the rows with PKs originally generated by
dataset stay in DataView, and new rows added with Access generated PKs are
added on resulting isn duplicated rows. Using datatable.clear solves problem
but seems sloppy. if i use RowUpdated i suppose i could acheive the same?
Miha Markic said:
Hi,

How are you doing updates?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

yes, i had just realized it was filtering before i could enter the new
filter column value and therefore 'disappearing'.

the real problem now seems to be that when the new row is Updated, the new
primary keys created by the database result in additional rows(duplicates)
in the DataSet and thus the Datagrid. Would calling the Datable.Clear()
before the Fill method be considered poor practice? Or is it better to use
RowUpdated to find the new primary keys and then change the old values?

thanks.


:

Hi,

Do you have any filtering on dataview or datagrid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

trying to add a new row by entering it directly in datagrid bound to
dataview.

after typing in value, new row disappears.
primary key is set to autoincrement.

also how to assign another value to another column in datatable at the
same time this datarow is being created through Dataview?
 

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