简体   繁体   中英

C# LINQ-to-SQL - not updating table with stored procedure

SOLVED

I have problems with Linq to SQL inserting/updating/deleting dataset from table with stored procedures.

  1. I have checked data connections, points on the same table that has been created when adding connection
  2. I'm using Linq-to-Sql classes designer for managing behavior of sprocs for my tables (insert, update, delete)
  3. I have same app created with different code style and everything works just fine but i can't include location change (when someone else installs app) in my .cs files, so I want to do it on "right way" and make it work for everyone.
  4. using sql server 2012 and vs2010

Here is my problem. this is included in form as reference for DataContext

private ZavrsniradDataContext poziv = new ZavrsniradDataContext();
//I've tried without private, and including this into methods where I'm  using it and nothing.

after I declare some variables for sending it to sproc I call sproc for altering the table..

poziv.p_IzmjenaMjesta(@ID, @Naziv, @PP, @IDZupanije);
poziv.SubmitChanges();

note: I'm sending ID number of the dataset I want to change, for comparison..

Alter proc [dbo].[p_IzmjenaMjesta]
@ID int,
@Naziv varchar(30),
@PP int,
@IDZupanije int
.
.
.
Update Mjesto 
SET Naziv= @Naziv, PostanskiPretinac = @PP, IDZupanije = @IDZupanije
WHERE ID = @ID;

After I call the sproc, my table is being refreshed, and all changes are visible. But after a while, all changes dissapear. I believe all my sprocs and functions are working properly, with my table, but somehow I'm doing something wrong. everything works perfecrly when I run sprocs in Management studio.

My other app contains this definition in beggining of the form, and everything works perfectly. updateing, inserting, deleting! But i don't want that solution because then I have to create fixed location for my database on every PC. I just want to install it and run it :)

public partial class Mjesta : Form
{
    ZavrsniRad poziv;

    public Mjesta()
    {
        InitializeComponent();
        poziv = new ZavrsniRad(@"c:\zavrsni_rad\Zavrsni rad.mdf");
    }

NOTE: I'm using exact copy of both databases on different locations with same sprocs/functions/dataset for different apps, and one is working, the other one is not working. and that grinds my gears :(

I have solved it. app is running and working properly... I forgot on that little thing :(

Problem solver, add all rights on modifying your database to every account you have. That also includes rights to log file.

(i dont have rep points for posting pics) http://www.pohrani.com/f/v/AQ/2bPLiVcP/slika.jpg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM