LINQtoSQL 不保存到数据库,但更改显示在应用程序中

发布于 2024-08-05 23:11:47 字数 274 浏览 1 评论 0原文

大家好,我有一个使用 C#express2008 和 sqlserverexpress 2005 的 linq 应用程序(mdf 文件连接) 我遵循常规 dml 生成和普通数据上下文。不过,我创建了一个存储库类来管理 Linq 内容。 在使用这些功能时,选择数据工作正常,更新数据在应用程序中工作。但是当我检查表中的数据时,没有任何变化。不用说,当我关闭应用程序时,也没有任何变化。 我使用 SQL Profiler 查看发送到 sqlserver express 的内容,但没有显示任何内容。

我的问题可能是什么?

Hey all, I have a linq app using C# express2008 and sqlserver express 2005 (mdf file connection)
I followed the regular dml generation and vanilla datacontext. However i created a repository class to manage the Linq stuff.
In using the functions, selecting data works fine, updating data works in the app.But when i check the data in the tables, nothing has changed.Needless to say, when i close the app, also no change.
I used SQL profiler to see what was being sent to sqlserver express, nothing showed up.

What could be my issues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江南月 2024-08-12 23:11:47

您是否在 DataContext 上调用 SubmitChanges() ?

Are you calling SubmitChanges() on the DataContext?

通知家属抬走 2024-08-12 23:11:47

没有主键,或者 L2S 模型中没有列标记为主键成员..?

No primary key, or no column(s) in the L2S model marked as primary key member(s)..?

青春有你 2024-08-12 23:11:47

好的...找到了“一个”解决方案。
1. 将(强制)默认连接字符串从查看文件更改为 sql server 实例(使用数据库而不是文件)
2.将文件附加到sql server express..并重命名db。

再次运行应用程序,一切正常。唯一的事情是..dml 仍然使用旧的连接字符串..所以对表的任何修改都必须在 sqlserver 中完成。
这只是我的快速补丁,有人愿意提供更详细的视图吗?

Ok... found 'a' soln.
1. changed (forced) default connection string from looking at a file to an instance of sql server (using database instead of file)
2. Attached file to sql server express..and renamed the db.

Ran app again and everything works. Only thing is..the dml still uses the old connection string..so any mods to tables have to be done in sqlserver.
This is just my quicky patch, anyone care to provide a more elaborate view?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文