Cannot add data to an SQL Server 2005 database

I have a simple form to display customers and add new ones. I have the customers displayed using a datagridview and bound datacontrols to display details about them when a a record is selected.

Anyway, I have an addition form for adding new 'Titles' for selection in a combobox.

I have created a button to add text and a new ID in the table tblTitles.

tblTitles looks like: TitleId | TitleDescription

tblTitles is related to tblCustomers from the TitleID to the TitleId in the customer table.

The code on the add title button is as follows. (Primary keys of each table is a GUID, "Sir" is just an example of a title)

Me.TblTitlesTableAdapter.Insert(Guid.NewGuid, "Sir")
Me.TblTitlesTableAdapter.Update(Me.NytdbDataSet)
Me.NytdbDataSet.AcceptChanges()

Any ideas why this isn't working


Answer this question

Cannot add data to an SQL Server 2005 database

  • ronnotel

    If I run the program directly from the bin folder, then it actually appears to work. I guess that is working then!

    Why is that Is my database being overwritten every time the debug is run

  • ayeesha

    Is your problem only occuring in debug mode

    Do a quick search in this forum on 'insert sql' and you'll probably find the information you need

  • tornin2

    Doh, how stupid I now feel! Thanks!

  • peiling

    If the db is added to your project, then every time you run the application the database is overwritten.

    To change this, view the properties of the database (solution explorer).
    There is a property called 'Copy to Output Directory'.

    set this to 'do not copy' or 'copy if newer'

    I think that should fix your problem

  • Cannot add data to an SQL Server 2005 database