locked
no data update when editing in WF on SQL db RRS feed

  • Question

  • I have set up a SQL database and connected my database to my Visual Studio project via the Add New Data Source option. I have created a form to show the data and also to update, delete. When I run the code I can see all the data in the assigned fields in the form. I can also add, update delete and while I have the form open the data remains. But I cannot see this data being saved back to the data set or database. As when I open the form again the previously edited data is not there. I can open the table designer and the option for the wizard to auto create Delete, Insert, and Update statements for the table is enabled. What could be wrong here?
    Thursday, March 15, 2018 9:01 PM

Answers

  • When you are debugging, the program folder is bin/debug (this is where your .exe is located). And this is where the .mdf was previously being copied so that your program could find it

    Since you are no longer copying your file to that location, 
    then you have to tell to your program where to find the .mdf. If it is in your
     source code folder, then you can modify your connection string like this:

    connectionString="Data Source=SQLSERVER;AttachDbFilename=..\..\db.mdf;Integrated Security=True;User Instance=True"

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Sunday, March 18, 2018 7:24 AM

All replies

  • Hi MeToo_,

    Have you checked the SQL Server log for some related error? Please use SQL Server Profiler to capture this process, if we can see some error message, please share it, if the session has not been created between VS and SQL Server or none data inserted, this can be a problem of Visual Studio, I suggest you opening a case in https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio

    Best Regards,

    Teige


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 16, 2018 5:59 AM
  • I have found my problem but no solution. Every time I run the application the database gets saved to the Debug folder and the original never gets updated. What could I do to either have the db not moved to Debug or point the db in Solution Explorer to the version in the Debug folder? I might want to make changes to the original db and know that everything will be overwritten if I change the orig and the one in the debug is not changed. Advice?
    Friday, March 16, 2018 1:57 PM
  • When you are debugging, the program folder is bin/debug (this is where your .exe is located). And this is where the .mdf was previously being copied so that your program could find it

    Since you are no longer copying your file to that location, 
    then you have to tell to your program where to find the .mdf. If it is in your
     source code folder, then you can modify your connection string like this:

    connectionString="Data Source=SQLSERVER;AttachDbFilename=..\..\db.mdf;Integrated Security=True;User Instance=True"

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Sunday, March 18, 2018 7:24 AM