如何将c#.net DataView(WPF)绑定到SQLite数据库? [英] How can I bind a c#.net DataView (WPF) to a SQLite database?
问题描述
我正在为我的应用程序使用官方的System.Data.SQLite ADO.NET提供程序,并且我试图在WPF DataGrid中显示数据库的内容。目前,我可以从数据库中选择需要显示的数据,但是我不知道如何在datagrid上显示数据。
I am using the official System.Data.SQLite ADO.NET provider for my application, and I am trying to display the contents of a database in a WPF DataGrid. Currently I am able to select the data I need to display from the database, but I don't how to display that data on the datagrid.
我在网络,阅读博客文章,教程和指南,但无济于事。我正在将应用程序从PHP系统(使用我的本地服务器)移动到桌面应用程序,以便跨系统移植。我当前的应用程序使用sqlite3数据库,并且包含相当多行。这就是为什么我更喜欢使用c#编写sqlite,这是我最适合的面向桌面的语言。
I have search on the web, read blog posts, tutorials and guides, but to no avail. I am moving an application from a PHP system (using my local server) to a desktop application to be portable across systems. My current applications uses sqlite3 databases, and contains quite a few rows. This is why I would prefer to make sqlite work with c#, which is the desktop oriented language I am most comfortable with.
推荐答案
您应该只需将列绑定到数据库中的字段名称。
You should just have to Bind the column to the name of the field in the db.
<local:AutoGenerateColumn Column="ItemStatusId"
Binding="{Binding Path=ItemStatusId}" />
这是一个很好的教程的链接:
http://www.codeproject.com/KB/WPF/DataGridAutoTemplate.aspx
Here's a link to a pretty good tutorial: http://www.codeproject.com/KB/WPF/DataGridAutoTemplate.aspx
这篇关于如何将c#.net DataView(WPF)绑定到SQLite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!