C # TableAdapter does not insert or update

I have a database called DB.mdf, in my program I am using this code to insert a new row into this database:

DBDataSet ds = new DBDataSet();
DBDataSetTableAdapters.IPTableAdapter ipadap = new DBDataSetTableAdapters.IPTableAdapter();

ipadap.InsertQuery(ip);

      

InsertQuery: INSERT INTO [IP] ([ID], [indirizzo]) VALUES (0, @indirizzo);

The program goes through all the steps, but does not insert a row into the database. Why?

UPDATE I have now tried this code:

DBDataset.IPRow newRegionRow;
newRegionRow = db.IP.NewIPRow();
newRegionRow.ID = "6";
newRegionRow.indirizzo = "NorthWestern";
// Add the row to the Region table
this.db.IP.Rows.Add(newRegionRow);
// Save the new row to the database
this.ipadap.Update(this.db.IP);

      

And in this case don't write a new line in the database

+3


source to share


1 answer


I found a bug !!! I didn't know that Visual Studio during development will create a copy of the database in / bin and work with the copy of the database.

Thanks everyone.



https://msdn.microsoft.com/en-us/library/ms246989.aspx

0


source







All Articles