C# WinFrom, Row already belongs to another table...

Hi all, code below keeps returning "Row already belongs to another table"

ive googled the error and have tried changing to

Rows.InsertAt
ImportRow

all bring back the same error!

anyone help me out?
DataRow NewMessage = dataSetClients.ClientMessaging.NewRow();
            NewMessage["RecordManager"] = GlobalFunc.UserName;
            NewMessage["Message"] = memoMessage.Text;
            NewMessage["ClientID"] = clientID;
            NewMessage["DateAdded"] = DateTime.Now;
            NewMessage["MessageSource"] = "User";

            dataSetClients dsNewMessage = new dataSetClients();
            dsNewMessage.ClientMessaging.Rows.Add(NewMessage);

            dataSetClientsTableAdapters.ClientMessagingTableAdapter taNewMessage = new dataSetClientsTableAdapters.ClientMessagingTableAdapter();
            taNewMessage.Update(dsNewMessage.ClientMessaging);
            MessageBox.Show("Aparently where updated! LIES!!!!!!");

Open in new window

LVL 1
awilderbeastAsked:
Who is Participating?
 
MathiyazhaganConnect With a Mentor Commented:
hope it is not neccassary to use two datasets...just create new dataset as u did:
dataSetClients dsNewMessage = new dataSetClients();
then directly add your new row and update as I attached.hope this helps.
dataSetClients dsNewMessage = new dataSetClients();
DataRow NewMessage = dsNewMessage .ClientMessaging.NewRow();
            NewMessage["RecordManager"] = GlobalFunc.UserName;
            NewMessage["Message"] = memoMessage.Text;
            NewMessage["ClientID"] = clientID;
            NewMessage["DateAdded"] = DateTime.Now;
            NewMessage["MessageSource"] = "User";

                       dsNewMessage.ClientMessaging.Rows.Add(NewMessage);
          dataSetClientsTableAdapters.ClientMessagingTableAdapter taNewMessage = new dataSetClientsTableAdapters.ClientMessagingTableAdapter();
            taNewMessage.Update(dsNewMessage.ClientMessaging);

Open in new window

0
 
awilderbeastAuthor Commented:
that was it!
thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.