ExecuteNonQuery() Not Working

徘徊边缘 提交于 2019-12-25 00:28:27

问题


Referring post : C# - ExecuteNonQuery() isn't working with SQL Server CE

I have the same problem with an attached Access Database to my Project and indeed i try to Insert records but all in vain, it tells me that it's inserted but no records found..

Well the above post discussed the problem and its cause but i want to know more about the solution... How Can i Solve this problem???

Best Regards,

Baher.


回答1:


I think I found out the Solution , after searching for sometime i did the following changes:

1- In the Solution Explorer I changed the property of my database which is Copy to Output Directory : always To Copy to output Directory : Do not Copy

2- In the Serve Explorer i right clicked my database and modified the Connection to it to the database which exists in my bin folder.

That's it...

Hope that it helps




回答2:


Are you using transactions? If yes, make sure that you are committing it or that you're not accidentally rolling back




回答3:


sir, i think the connection is already open since the query did not throw any exception, w

sir what does ur query look like? String representation, since if you have a WHERE clause, and the field is missing,or if ur updating, a WHERE claause would not throw an exception and would tell you that everything is inserted but probably not, since it has accessed the databse and looked for the table, but didnt find any variables, it just passed....




回答4:


  1. check that your connection is open when you execute in c#
  2. check that you have no uncommitted transaction in sql


来源:https://stackoverflow.com/questions/4295853/executenonquery-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!