Database.mdf没有使用wpf在表中插入任何值? [英] Database.mdf is not inserted any values in table using wpf?

查看:77
本文介绍了Database.mdf没有使用wpf在表中插入任何值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在wpf中创建了database.mdf,之后我插入了值,一旦在数据库表中没有显示任何值后关闭此应用程序,就会立即在datagrid中查看。我不知道发生了什么事?如果知道有人帮我解决这个问题。 

I created database.mdf in wpf after i was inserting values to see promptly in datagrid once close this application after not showing any values in database table. i don't know what is happening? if know anyone help me out from this. 

谢谢&问候

Murugansilvers

Murugansilvers

推荐答案

这可能是因为Visual Studio正在使用两个数据库文件的副本。一个是您在源代码文件夹中创建的,其内容在运行时永远不会更改。另一个副本位于bin / debug文件夹中,这是你的程序写入的
。每次运行程序时,源代码中的原始文件都会复制到bin文件夹中的文件中,因此所有更改都会丢失,并且您的程序似乎没有写任何内容。您可以更改
这个默认行为。在Visual Studio中,单击解决方案资源管理器中的数据库并检查"属性"。更改显示"始终复制"的那个。或者,更改连接字符串,使其指向源文件夹中的文件
而不是可执行文件夹中的文件。
This is probably because Visual Studio is using two copies of the database file. One is the one that you created in the source code folder, and its contents never change at runtime. The other copy is in the bin/debug folder, and this is the one that your program is writing to. Every time you run the program, the original file in the source code is copied over the file in the bin folder, so all of the changes are lost, and it appears that your program did not write anything.You can change this default behavior. In Visual Studio, click on the database in Solution Explorer and examine the Properties. Change the one that says "Copy always". Or alternatively, change the connection string so that it points to the file in the source folder, instead of the file n the executable folder.


这篇关于Database.mdf没有使用wpf在表中插入任何值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆