   Row not being added to my DataSet
  I have a problem and I don't know why.First some code:private void newsItems_Show()   {  Lesson13b.NewsItemContainer nIS = new NewsItemContainer();  nIS.Title = "The Dumps";  nIS.Description = "A test.";  nIS.Link = "http://www.gamedev.com/xml";  RSSDBDataSet1.NewsItemRow newRow = rSSDBDataSet1.NewsItem.NewNewsItemRow();  MessageBox.Show(newRow.NewsItemID.ToString()); // error 2  newRow.Title = nIS.Title;  newRow.Description = nIS.Description;  newRow.Link = nIS.Link;  newRow.DateAcquired = DateTime.Now;  newRow.ChannelID = (int)channelsListBox.SelectedValue;  rSSDBDataSet1.NewsItem.AddNewsItemRow(newRow); //error 1  newsItemTableAdapter.Update(newRow);   }private void addFolder()    {  Form2 f = new Form2();  f.FolderID = 0;  f.FolderName = "";  DialogResult result = f.ShowDialog();  if (result == DialogResult.OK)  { MessageBox.Show("It's OK!");  RSSDBDataSet1.FolderRow folder = rSSDBDataSet1.Folder.NewFolderRow(); folder.BeginEdit();  folder.FolderName = f.FolderName; folder.EndEdit(); MessageBox.Show(folder.FolderID.ToString()); rSSDBDataSet1.Folder.AddFolderRow(folder); int rowsAffected = folderTableAdapter.Update(rSSDBDataSet1.Folder);  }  else  { MessageBox.Show("No, still needs work...");  }  f = null;   }Both do the same thing, add a new Row to the DataSet then Updates it to the Database. The problem is that addFolder works just fine. newsItems_Show() errors out, always. Where you see error 1, I get the error NewsItemID doesn't accept Nulls. Now when I put the MessageBox there to see what NewsItemID is I get InvalidCastException, when casting from an int, value must be less than infinity. It doesn't matter whether I put MessageBox before Title or after ChannelID. I get the same error. Does anyone why this could be happening and how to fix it?edit: due to requests and my obviously not knowing what the hell i'm talking about. this thread is now open. thanks; therefore not [solved] or [unsolved].[Edited by - Alpha_ProgDes on June 20, 2006 8:28:23 PM]
  I guess this is C# right?Can't you step in using a debugger to see the value of NewsItemID?  Is it possible that its uninitialized?I hope I could be more helpful, but that's all I can think of for tonight (I'm no C# pogrammer and haven't messed with this kind of stuff hehe)   ;Quote:Original post by xEricxI guess this is C# right?Can't you step in using a debugger to see the value of NewsItemID?  Is it possible that its uninitialized?I hope I could be more helpful, but that's all I can think of for tonight (I'm no C# pogrammer and haven't messed with this kind of stuff hehe)I tried that. Couldn't find the value... there's so many of them! And yeah this is C#.;  Have you tried to say... assign it 0 or something just to see if that could be the problem?I guess you're not the one who wrote NewNewsItemRow()?What RSS library are you using?  maybe they might have some documentation on NewsItemID?   ;  Here's the answer: It seems my NewsItems Table was getting initialized incorrectly. How I don't know. But. Here's what I did to correct it:> Click on the Data Sources tab (that's where your DataSets are)> Right-click on the DataSet's Name and choose Edit DataSet with Designer> Choose (Left-click once) on the Table you want then choose the Properties Tab to your bottom right (that's default configuration, if you haven't messed with anything)> Again choose the Field you want (you might have to hit the Properties Tab again) and make sure: AutoIncrement = True, AutoIncrementSeed = 0, AutoIncrementStep = 1It should all work then. Now I have to figure how to delete a collection of DataRows from my DataSet...   ;  DataSets and C# SUCK!!still having original issue...Now when I actually update the my DataSet I get this:Cannot insert explicit value for identity column in table 'NewsItem' when IDENTITY_INSERT is set to OFF.Where the hell do I change that!?   ;  You need to change your table definition to make sure NewsId isn't an identity. alter table NewsItem alter column NewsId int not null   ;Quote:Original post by evolutionalYou need to change your table definition to make sure NewsId isn't an identity. alter table NewsItem alter column NewsId int not nullNewsItemID is a PrimaryKey and an 'isIdentity' (that's how it autoincrements).and it's an int and not doesn't allow nulls;Quote:Original post by Alpha_ProgDesQuote:Original post by evolutionalYou need to change your table definition to make sure NewsId isn't an identity. alter table NewsItem alter column NewsId int not nullNewsItemID is a PrimaryKey and an 'isIdentity' (that's how it autoincrements).and it's an int and not doesn't allow nullsIt's not C#'s fault.  You have your database setup to not let you insert the identity values, and that is probably the way it should be.  Just redo your querry so that it doesn't try to insert the ID, and the database will take care of creating one.   ;Quote:Original post by intrest86Quote:Original post by Alpha_ProgDesQuote:Original post by evolutionalYou need to change your table definition to make sure NewsId isn't an identity. alter table NewsItem alter column NewsId int not nullNewsItemID is a PrimaryKey and an 'isIdentity' (that's how it autoincrements).and it's an int and not doesn't allow nullsIt's not C#'s fault.  You have your database setup to not let you insert the identity values, and that is probably the way it should be.  Just redo your querry so that it doesn't try to insert the ID, and the database will take care of creating one.well that's strange because I set all of them up the same way and only NewsItems gives me that problem. so I say it's C#'s fault [smile]