WPF嵌入式数据库应用程序 [英] WPF Embedded Database Application

查看:174
本文介绍了WPF嵌入式数据库应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WPF的新用户,我想使用WPF中的嵌入式(本地)数据库来创建一个小型应用程序。我使用 VS08 , - >添加新文件 - >本地数据库。

I'm new with WPF and I want to make a small application with the embedded (local) database in WPF. I'm using VS08, --> add new file --> local Database.

我也可以添加一个表(名为Person和Person的测试表)。现在有我的问题,任何人都可以告诉我如何使(select ... insert)语句在codebehind,以便我可以显示在datagrid(从wpftoolkit)。

I can also add a table (test table called Person with Name and Age). And now comes my problem, could anyone tell me how to make (select... insert) statements in codebehind, so that I could display them in a datagrid (from wpftoolkit).

推荐答案

此文章包含您需要的所有代码:

This Article has all the code you need:

WPF ListView中的数据绑定

您可能需要修改数据库代码有点:

You might want to modify the Database code a little though:

using(SqlConnection conn = new SqlConnection(connectionString))
{
    // Rest of the code goes here.
    // You no longer have to explicitly close the connection either.
}

虽然,如果你的应用程序要做任何事情,以更好的方式来处理数据管理和绑定,如MVVM模式。

Although, if your application is going to do anything even remotely complicated I would look into better ways to handle data management and binding like the MVVM pattern.

这篇关于WPF嵌入式数据库应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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