检查SQL Server CE数据库插入功能应用评估后 [英] Check SQL Server CE database after INSERTION for application evaluation

查看:74
本文介绍了检查SQL Server CE数据库插入功能应用评估后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对插入下面的脚本到SQL Server CE数据库

 的SqlCeConnection CON =新的SqlCeConnection(); 
Con.ConnectionString =(@数据源= | DataDirectory目录| \Database.sdf;密码=密码;);
Con.Open();
SqlCeCommand查询=新SqlCeCommand(插入用户(ID,名称,FName参数,地址,的MCode,MNUM,金额)VALUES(@ ID,@名称,@ FName参数,@地址,@代码,@民,@量),刀豆)
Query.Parameters.AddWithValue(@ ID中,ID + 1);
Query.Parameters.AddWithValue(@名,NBox.Text);
Query.Parameters.AddWithValue(@ FName参数,SOBox.Text);
Query.Parameters.AddWithValue(@地址,AdBox.Text);
Query.Parameters.AddWithValue(@代码,Convert.ToInt32(MCode.Text));
Query.Parameters.AddWithValue(@民,Convert.ToInt32(MNum.Text));
Query.Parameters.AddWithValue(@金额,Convert.ToInt32(AmBox.Text));

INT rowsEffected = Query.ExecuteNonQuery();

MessageBox.Show(rowsEffected.ToString());

在插入消息框显示行受到影响= 1 这意味着成功插入到数据库中,我使用VC#2010的文件复制性能数据移动数据库文件调试/斌/发布文件夹,当我检查我的数据库文件在我的项目文件夹是空的,因为斌/发布文件是在Solution Explorer外面看不见,所以我不能够检查它,我想检查评估,即数据我的数据库文件正确插入与否



请告诉我如何做到这一点。



谢谢!


解决方案

下面是你的问题:



...文件拷贝属性数据库文件移动到调试/斌/释放文件夹,当我检查我的数据库文件在我的项目文件夹为空

在项目文件夹中的数据库文件是原始的,不变的源数据。当你建立你的应用程序的Visual Studio副本(不移动)原项目文件到您的输出文件夹(斌/释放任何或)。您的代码插入数据的副本,而不是原来的不变的数据。



要检查您的数据库文件进行评估你必须检查的副本,而不是原来的,不变,源文件。你可以做,要么从插入数据,也使用 DataDirectory目录属性如果是在相同的输出文件夹,也可以打开一个测试应用程序相同的应用程序文件中的输出目录(在你的案件斌/释放)。



...斌/释放文件是解决方案资源管理外部可见...

是的,因为这不是你的项目的一部分。它的输出数据,就好像你叫 Stream.Write Console.Writeline 。原来,不变的源数据源的一部分,就像你的.cs文件。它不传递给用户或者通过运行你的应用程序改变。你必须以测试斌/释放复制或什么的。


I have the following script for insertion into a SQL Server CE database

SqlCeConnection Con = new SqlCeConnection();
Con.ConnectionString = (@"Data Source=|DataDirectory|\Database.sdf;Password=Password;");
Con.Open();
SqlCeCommand Query = new SqlCeCommand("INSERT INTO Users(ID,Name,FName,Address,MCode,MNum,Amount) VALUES(@ID,@Name,@FName,@Address,@Code,@Num,@Amount)", Con)
Query.Parameters.AddWithValue("@ID", ID + 1);
Query.Parameters.AddWithValue("@Name", NBox.Text);
Query.Parameters.AddWithValue("@FName", SOBox.Text);
Query.Parameters.AddWithValue("@Address", AdBox.Text);
Query.Parameters.AddWithValue("@Code", Convert.ToInt32(MCode.Text));
Query.Parameters.AddWithValue("@Num", Convert.ToInt32(MNum.Text));
Query.Parameters.AddWithValue("@Amount", Convert.ToInt32(AmBox.Text));

int rowsEffected=Query.ExecuteNonQuery();

MessageBox.Show(rowsEffected.ToString());

After insertion the message box show rows affected=1 this means that data successfully inserted into database I am using VC# 2010 as file copy property moves database file to Debug/Bin/Release folders and when I check my database file in my project folder it is empty as Bin/Release file is visible outside the Solution Explorer so I am not able to check it I want to check my DB file for evaluation i-e data is inserted properly in it or not

Kindly tell me how to do this

Thanks!

解决方案

Here's your problem:

... file copy property moves DB file to Debug/Bin/Release Folder and when i check my database file in my project folder it is empty

The database file in your project folder is the original, unchanged source data. When you build your app Visual Studio copies (not moves) the original project file to your output folder (Bin/Release or whatever). Your code inserts the data into the copy, not the original unchanged data.

To "check your DB file for evaluation" you have to check the copy, not the original, unchanged, source file. You can do that either from the same app that inserts the data, from a test app that also uses the DataDirectory property if it is in the same output folder, or you can open the file in the output directory (Bin/release in your case).

... Bin/Release file is visible outside the Solution explorer ...

Yes, because it is not part of your project. It is output data as if you called Stream.Write or Console.Writeline. The original, unchanged source data is part of your source, like your .cs files. It is not delivered to the user or changed by running your app. You have to test the copy in Bin/Release or whatever.

这篇关于检查SQL Server CE数据库插入功能应用评估后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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