且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新数据库上的查询字符串

更新时间:2023-11-07 18:47:28

1。为数据库设置约束以防止双重输入。

2.在我看来,SubmitChanges认为记录是新记录。 (你也可以学生addStudents =新学生; 所以它实际上是一个新纪录) - >我在这里假设您省略了一些代码行?您应该从db对象中获取EXISTING值(或者绑定到此对象的任何对象),更改值然后调用SubmitChanges。

3.如果您告诉我们什么是数据库会有所帮助你正在努力。

4.你在使用LINQ吗?在这种情况下,SubmitChanges将生成一个SQL,您可以在Visual Studio的输出窗口中看到该SQL。如果您正在插入或更新,它会立即告诉您。



如果您使用更多代码更新问题,可能会更好。



希望这会有所帮助。
1. Set constraints to your database to prevent double entries.
2. It looks to me like the SubmitChanges thinks the records is a new one. (You also do Students addStudents=new Students; so it is in fact a new record) --> I assume here that you omitted some lines of code? You should get out the EXISTING value from the db object (or whatever object is bound to this), change the values and then call SubmitChanges.
3. It would help if you would let us know what database you're working on.
4. Are you working with LINQ? in that case the SubmitChanges will generate an SQL which you can see in the output window of Visual Studio. That will immediately tell you if you're inserting or updating.

It's probably better if you update your question with a little more code.

Hope this helps.