• C# 读取 Access


    通过using语句实现非GC资源的自动回收。

    还需要有try…catch…之类的异常检测语句,检测file.exist。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

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

    namespace ReadAccess
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=school.mdb"))
                {
                    conn.Open();

                    string sql = "select * from sheet1 where student='stu2'";

                    OleDbCommand command;

                    command = new OleDbCommand(sql, conn);

                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        //1次读取1个记录
                        while (reader.Read())
                        {

                            for (int i = 0; i < reader.FieldCount; i++)
                            {

                                Console.Write("{0} ", reader[i]);

                            }

                            Console.WriteLine();

                        }
                    }
                }
            }
        }
    }

  • 相关阅读:
    postgresql 简单入门
    自用 docker-compose
    前后端分离 开发环境通过CORS实现跨域联调
    导出 java.io.IOException: 权限不够
    mysql 数值与字符类型 长度梳理
    easyui input未设id导致的问题
    springmvc处理url请求步骤
    js中的变量提升(hoisting)
    auto semicolon insertion 自动分号补齐的坑
    $.ajax dataType设置为json 回调函数不执行
  • 原文地址:https://www.cnblogs.com/johnpher/p/2872624.html
Copyright © 2020-2023  润新知