首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有人在SharpDevelop中使用SharpDevelop吗?

有人在SharpDevelop中使用SharpDevelop吗?
EN

Stack Overflow用户
提问于 2009-07-04 23:47:04
回答 1查看 5K关注 0票数 2

我只是想知道你们中是否有人成功地将SQLite集成到SharpDevelop项目中?如果是这样的话,如果你不介意和我们一起分享经验的话,那就很有趣了。

我尝试过一种更传统的方法,使用Visual 2008速成版和诸如此类的东西,但是,尽管它显然与Visual Web Developer很好地合作,但不幸的是,SQlite.NET失败Visual C#一起工作,所以SharpDevelop是我现在唯一的希望。

提前谢谢大家。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-07-06 03:36:17

在谷歌大量搜索并混合了各种来源和方法之后,我找到了一种方法来解决这个问题。下面是最重要的代码片段:

代码语言:javascript
复制
/// <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元素。

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1083187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档