是使用System.Data.SQLite内SharpDevelop的人? [英] Is anyone using System.Data.SQLite within SharpDevelop?

查看:187
本文介绍了是使用System.Data.SQLite内SharpDevelop的人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如果任何或许你们已经是成功整合的的SQLite SharpDevelop的的项目?如果是这样的情况下,这将会是非常有趣的,如果你不介意继续前进,并与我们分享其他地区的经验。

I was just wondering if perhaps any of you guys has been successful integrating SQLite into a SharpDevelop project? If that's the case it'd be really interesting if you wouldn't mind to go ahead and share the experience with the rest of us.

我已经试过了更多样的使用 Visual Studio 2008的前preSS版和诸如此类的东西,但正统的方法,虽然它显然起着很好地与 Visual Web Developer中,遗憾的是在 SQlite.NET 失败 Visual C#中工作,所以SharpDevelop的是pretty的多我唯一的希望了。

I've tried the more sort of orthodox approach of using Visual Studio 2008 Express Editions and whatnot but, although it apparently plays well with Visual Web Developer, unfortunately the SQlite.NET package fails to work with Visual C#, so SharpDevelop is pretty much my only hope now.

感谢大家提前。

推荐答案

在Google上搜寻了很多和混合各种渠道和办法,我已经找到一种方法来acomplish此之后。这里有最显著code的一个片段:

After googling a lot and mixing a variety of sources and approaches I've found a way to acomplish this. Here's a snippet of most significant code:

/// <remarks>
/// Creating a DataSet to feed the DataGridView
/// </remarks>  		
// 
DataSet results = new DataSet();
try
{
    /// <remarks>
    /// Setting the path where the database file is located
    /// </remarks>
    string database = "X:\\path\\to\\database\\file\\books.db";
    /// <remarks>
    /// Creating a ConnectionString pointing to the database file
    /// </remarks>
    SQLiteConnectionStringBuilder datasource = new SQLiteConnectionStringBuilder();
    datasource.Add("Data Source", database);
    datasource.Add("Version", "3");
    datasource.Add("New", "False");
    datasource.Add("Compress", "True");	            
    /// <remarks>
    /// Starting the connection and sending the query
    /// </remarks>	            
    using (SQLiteConnection connection = new SQLiteConnection(datasource.ConnectionString))
    {
    	using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(queryTextBox.Text, connection))
    	{
    		/// <remarks>
    		/// Populating the DataGridView
    		/// </remarks>
    		adapter.Fill(results);
    		resultsDataGridView.DataSource = results.Tables[0].DefaultView;
    	}
    }
}
catch (Exception error)
{
    MessageBox.Show("Exception caught: " + error.Message);
}

其中 resultsDataGridView 已创建与IDE和 queryTextBox 是包含SQL语句中的TextBox元素。

Where resultsDataGridView has been created with the IDE and queryTextBox is a TextBox element containing the SQL statement.

不要忘了添加的引用 System.Data.SQLite.dll 及其相应的使用指令。

Don't forget to add a reference to System.Data.SQLite.dll and its corresponding using directive.

这篇关于是使用System.Data.SQLite内SharpDevelop的人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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