zoukankan      html  css  js  c++  java
  • Access数据库连接字符串

    <connectionStrings>
    <add name="connStr" connectionString="server=.;uid=home;pwd=;database=EFFristModel"/>
    <!--<add name="connStr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|EFFristModel.mdb" providerName="System.Data.OleDb"/>-->
    </connectionStrings>

    Access数据库的SqlHelper

    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Data.OleDb;
    namespace CZBK.BookShop.AccessDal
    {
    public class SqlHelper
    {
    private readonly static string connectionString =ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
    public static DataTable GetTable(string sql, CommandType type, params OleDbParameter[] pars)
    {
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
    using (OleDbDataAdapter apter = new OleDbDataAdapter(sql, connection))
    {
    if (pars != null)
    {
    apter.SelectCommand.Parameters.AddRange(pars);
    }
    DataTable da = new DataTable();
    apter.SelectCommand.CommandType = type;
    apter.Fill(da);
    return da;
    }
    }
    }
    }
    }

  • 相关阅读:
    P1662 数7
    P3645 [APIO2015]雅加达的摩天楼
    P3396 哈希冲突
    P7479 至曾是英雄的您
    P7480 Reboot from Blue
    Apache Commons Collections
    ESP8266 WIFI杀手
    ESP8266 固件升级
    ESP8266 MicroPython安装与使用
    Window 安装子系统
  • 原文地址:https://www.cnblogs.com/jiangyunfeng/p/11244930.html
Copyright © 2011-2022 走看看