zoukankan      html  css  js  c++  java
  • C# 连接sqlite数据库

     web.config 

    <connectionStrings>
    <add name="SQLiteDB" connectionString="Data Source=C:UsersDesktop est.db"/>
    </connectionStrings>

    public class ProductService
    {
    public static readonly ProductService Instance = new ProductService();
    private static string connstr = ConfigurationManager.ConnectionStrings["SQLiteDB"].ConnectionString;

    public DataTable GetData()
    {
    SQLiteConnection conn = null;
    int num = 0;
    int productNum = 10;
    try
    {
    conn = new SQLiteConnection(connstr);
    conn.Open();
    string sql = "select * from users";
    //SQLiteParameter[] parameter = { new SQLiteParameter("@product", product), new SQLiteParameter("@productNum", productNum) };
    SQLiteCommand cmd = new SQLiteCommand(sql, conn);
    //cmd.Parameters.AddRange(parameter);
    SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
    DataTable dt = new DataTable();
    sda.Fill(dt);

    return dt;
    }
    catch (Exception ex)
    {
    return null;
    }

    }
    }

  • 相关阅读:
    PHP中each与list用法分析
    三大范式通俗讲解
    数据库三大范式详解
    利用JS制作简便计算器
    CSS下拉列表错误纠正
    下拉列表
    CSS选择器、标签,div的位置。
    php注册审核
    php分页查询
    php投票练习
  • 原文地址:https://www.cnblogs.com/LiChen19951127/p/10288340.html
Copyright © 2011-2022 走看看