惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
Cloudbric
Cloudbric
Recent Commits to openclaw:main
Recent Commits to openclaw:main
I
Intezer
Attack and Defense Labs
Attack and Defense Labs
P
Privacy International News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
C
Cybersecurity and Infrastructure Security Agency CISA
V2EX - 技术
V2EX - 技术
AWS News Blog
AWS News Blog
O
OpenAI News
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
Arctic Wolf
Spread Privacy
Spread Privacy
G
GRAHAM CLULEY
T
Tor Project blog
博客园_首页
Know Your Adversary
Know Your Adversary
有赞技术团队
有赞技术团队
S
Secure Thoughts
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Visual Studio Blog
J
Java Code Geeks
Cisco Talos Blog
Cisco Talos Blog
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security Affairs
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
宝玉的分享
宝玉的分享
量子位
Last Week in AI
Last Week in AI
月光博客
月光博客
罗磊的独立博客
S
SegmentFault 最新的问题

博客园 - weekzero

百度编辑器ueditor批量上传图片或者批量上传文件时,文件名称和内容不符合,错位问题 代码漏洞扫描描述Cross Site History Manipulation解决办法[dongcoder.com] iis重写模块实现程序自动二级域名,微软提供的URL重写2.0版本适用IIS以上 借助微软提供的url重写类库URLRewriter.dll(1.0)实现程序自动二级域名,域名需要泛解析 AspNetPager控件报错误: Syntax error, unrecognized expression: input#ctl00$ContentPlaceHolder1$Aspnetpager1_input问题解决[摘] 精准定位才能赢得人心 IIS7.5打开GZip压缩,同时启用GZip压缩JS/CSS文件的设置方法 c#变量缺少using引用,如何快速加上using,加Using的快捷键 chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法 要用于尝试,广东移动间接实现“流量不清零” jquery中ajax在firefox浏览器下“object XMLDocument”返回结果的解决办法 mvc中Url.RouteUrl或者Html.RouteLink实现灵活超链接,使href的值随路由名称或配置的改变而改变 mvc中多参数URL会很长,首次加载不传参数让url很短,路由规则实现方法 《舌尖上的中国》第二季今日首播了,天猫食品也跟着首发,借力使力 Ubuntu 14.04 (Trusty Tahr) LTS发布,附下载地址,各种镜像 大数据量下,分页的解决办法 winform设置button的边框颜色,或取消边框颜色,不显示边框 winform里操作打开在panel里的form窗体,子窗体操作同级子窗体或者父窗体的方法 cWeb开发框架,基于asp.net的cWeb应用开发平台介绍(二)
System.Data.OleDb操作access数据库类
weekzero · 2014-04-13 · via 博客园 - weekzero

access数据库在应用了System.Data.OleDb后操作会很方便,这是一个常用的数据库操作类,其中两个方法,一个是返回datatable的,一个是执行sql语句返回影响记录的(一般是insert,update、delete等)。 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data;
using System.Data.OleDb;

/// <summary>
///DB 的摘要说明
/// </summary>
public class DB
{
    public string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("bubuko.mdb");

    public DataTable GetDt(string sql)
    {
        DataSet ds = new DataSet();
        OleDbConnection conn = new OleDbConnection(connStr);

        if (conn.State == ConnectionState.Closed) conn.Open();
        OleDbDataAdapter da = new OleDbDataAdapter(sql, conn);

        da.Fill(ds);
        conn.Close();
        return ds.Tables[0];
    }

    public int RunSql(string sql)
    {
        try
        {
            OleDbConnection conn = new OleDbConnection(connStr);

            if (conn.State == ConnectionState.Closed) conn.Open();
            OleDbCommand comm = new OleDbCommand(sql, conn);

            comm.ExecuteNonQuery(); conn.Close();
            return 1;
        }
        catch { return 0; }
    }

}