数据未保存在(内置)数据库中(Windows应用程序) [英] data is not saving in (inbuilt) database (windows application)

查看:84
本文介绍了数据未保存在(内置)数据库中(Windows应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了Windows应用程序(Payroll).最初我创建了外部数据库.但是我必须在系统中安装.现在,我在内置数据库中创建查询已经执行了.关闭关闭应用程序后,数据无法保存
是问题所在.
我尝试了很多次.
请在这种情况下帮助我
在此先感谢,
KS
这是代码
con =新的SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings ["con"].ToString();
cmd = new SqlCommand(插入TDept值(""+ TXT_TDName.Text +"''),con);
//cmd.CommandText = q;
//cmd.CommandType = CommandType.Text;
//cmd.Parameters.AddWithValue("@TDName,TXT_TDName.Text);
con.Open();
int r =(int)cmd.ExecuteNonQuery();

解决方案

kalyansantosh写道:

i开发了Windows应用程序(工资单).



但是您将问题标记为ASP.NET....


kalyansantosh写道:

cmd = new SqlCommand(插入TDept值(""+ TXT_TDName.Text +")",con) ;



您明显的问题是您的代码很烂.这是在真实系统上安装的吗?您确定您的用户都不会尝试利用这种糟糕的代码来清除数据库吗?我想这是一个本地数据库,所以他们只会伤自己.它仍然是糟糕的形式.

您不会说您创建的是哪种类型的数据库,或者它位于何处.您也不会说您正在运行什么操作系统.如果数据库文件位于应用程序的文件夹中,则Vista和Weven将给您带来各种安全问题.

编辑您的帖子,放入正确的标签,告诉我们哪个数据库,告诉我们连接字符串,以及数据库的位置.解释一下您的意思-更改是否发生但在再次启动应用程序时消失,还是根本不发生?


i developed a Windows apllication (Payroll). Intially i created External database.But i have to install in systems. Now im creating in built database already queries are executed. After closing the closing the application the data is not saving
Wt is the problem.
i tried so many times.
Please help me out in this situation
Thanks in Advance,
KS
This is the code
con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["con"].ToString();
cmd = new SqlCommand("insert into TDept values(''" + TXT_TDName.Text + "'')", con);
//cmd.CommandText = q;
//cmd.CommandType = CommandType.Text;
//cmd.Parameters.AddWithValue("@TDName", TXT_TDName.Text);
con.Open();
int r = (int)cmd.ExecuteNonQuery();

解决方案

kalyansantosh wrote:

i developed a Windows apllication (Payroll).



Yet you tagged your question as ASP.NET....


kalyansantosh wrote:

cmd = new SqlCommand("insert into TDept values(''" + TXT_TDName.Text + "'')", con);



your obvious problem is that your code sucks. This is installed on real systems ? You''re sure none of your users will try to exploit the odds of the code being this bad, and erase your database ? I guess it''s a local DB, so they only hurt themselves. It''s still poor form.

You don''t say what sort of DB you create, or where it lives. You also don''t say what OS you''re running on. If the DB file is in the folder with the application, then Vista and Weven will give you all sorts of security issues.

Edit your post, put the right tags in, tell us what database, tell us the connection string, and where the DB lives. Explain what you mean - do the changes occur but disappear when the app is started again, or do they not occur at all ?


这篇关于数据未保存在(内置)数据库中(Windows应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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