VS2010中带有内置sql数据库的Probelm,带有c#的窗口应用程序 [英] Probelm with inbuilt sql database in VS2010 ,window application with c#

查看:105
本文介绍了VS2010中带有内置sql数据库的Probelm,带有c#的窗口应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在c#4.0中创建了一个窗口应用程序,我在VS2010中使用了内置的sql数据库(.mdf datbase).之前它工作正常.但是现在我注意到其中存在一个问题.
工作:
1)用户被添加到数据库,并通过插入新的一行被ExecuteNoQuery返回1确认.
2)然后再添加下一个用户,因为前一个用户ID为1,它检查最后一个ID,并将ID递增1.它也被成功添加.

3)搜索操作也可以正常工作.


但是,当我关闭应用程序时,没有任何内容保存在数据库中.我刷新数据库
之后也什么也没发生.
1
因此,当我重新启动应用程序时,用户ID再次从1开始.

在较早的时候将新数据库添加到项目中时,仅创建具有mdf和日志文件的数据库.但这一次它还会创建DrishyaDatabaseDataSet.xsc文件.(一旦删除它们,它们是否很重要)

I have created a window application in c# 4.0, i used inbuilt sql database (.mdf datbase) in VS2010. earlier it was working fine. But now i noticed a problem in it.
working:
1)user get added to the database, that is confirmed by ExecuteNoQuery return 1, as new one row is inserted.
2)Then next user is also added, as previous user id was 1, it check last id and increment id by 1. it also get successfully added.

3)Search operation also work properly.


But when i close the application, nothing get saved in database. I refresh database
after that also nothing happened.
1
So when i restart application, user id again start from 1.

When earlier add new database to project, only database with mdf and log file was created. But this time it also create DrishyaDatabaseDataSet.xsc files.(Once i deleted them , were they important)

推荐答案

除非您使用了xsc文件,否则xsc文件中将不包含信息.新数据源窗口,以定义数据集中数据字段的默认控件绑定.当您将数据表拖到WinForm上以生成默认UI时,将使用该信息.如果使用此功能,并在数据源窗口中更改绑定控件,则文件将包含这些设置.如果删除此文件,则将丢失这些设置.但是,如果您不使用此文件,则不需要此文件.

您的问题似乎是
1.您可以使用未提交的交易:
在结束交易前进行任何交易.


2.您的数据库每次创建:
Initial Catalog = Database1;数据源=<服务器名="="> ;;集成安全性= True; 用户实例= False
The xsc file does not contain information unless you are using the new data sources window to define default control binding for the data fields in your data set. That information will be used when you drag the data table to a WinForm to generate a default UI. If you are using this function, and change the binding controls in the data source window, the file will contain those settings. You would lose those settings, if you delete this file. However, if you don''t use this, you don''t need this file.

Your issue seems like
1. You may used uncommited transaction:
Commit any transactions before you close out.

or
2. Your DB is created every time:
Initial Catalog=Database1;Data Source=<server name="">;Integrated Security=True;User Instance=False


这篇关于VS2010中带有内置sql数据库的Probelm,带有c#的窗口应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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