using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace TestUDL {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }

OleDbDataAdapter ad;         DataSet ds;         public void fanfa() {             //string connectString = "Data Source=localhost;Initial Catalog=MytestDB;Integrated Security=SSPI";             //SqlConnection sqlConnect = new SqlConnection(connectString);             string connectString = @"File Name=D:\VS2015Programming\MyTest\TestUDL\TextFile1.udl;";             OleDbConnection conn = new OleDbConnection(connectString);             conn.Open();             OleDbCommand sqlCommand = conn.CreateCommand();             string sqlCommandText = "SELECT [ID],[Name] FROM[MytestDB].[dbo].[PersonTable]";             sqlCommand.CommandText = sqlCommandText;             //OleDbDataReader sqlDataReader = sqlCommand.ExecuteReader();             ad = new OleDbDataAdapter(sqlCommand);             OleDbCommandBuilder bb = new OleDbCommandBuilder(ad);             ad.UpdateCommand = bb.GetUpdateCommand();             ad.InsertCommand = bb.GetInsertCommand();             ad.DeleteCommand = bb.GetDeleteCommand();              ds = new DataSet();             ad.Fill(ds);         }         private void button1_Click(object sender, EventArgs e)         {             ////string connectString = "Data Source=localhost;Initial Catalog=MytestDB;Integrated Security=SSPI";             ////SqlConnection sqlConnect = new SqlConnection(connectString);             //string connectString = @"File Name=D:\VS2015Programming\MyTest\TestUDL\TextFile1.udl;";             //OleDbConnection conn = new OleDbConnection(connectString);             //conn.Open();             //OleDbCommand sqlCommand = conn.CreateCommand();             //string sqlCommandText = "SELECT [ID],[Name] FROM[MytestDB].[dbo].[PersonTable]";             //sqlCommand.CommandText = sqlCommandText;             ////OleDbDataReader sqlDataReader = sqlCommand.ExecuteReader();             //OleDbDataAdapter ad = new OleDbDataAdapter(sqlCommand);             //DataSet ds = new DataSet();             //ad.Fill(ds);             fanfa();             this.dataGridView1.DataSource = ds.Tables[0];         }

private void button2_Click(object sender, EventArgs e)         {             DataTableCollection ss = ds.Tables;             //ds.Tables[0].Rows[5].RowState = DataRowState.Added;             this.ad.Update(ds.Tables[0]);         }     } }

OleDbDataAdapter具体使用11的更多相关文章

  1. 地区sql

    /*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...

  2. WinForm 天猫2013双11自动抢红包【源码下载】

    1. 正确获取红包流程 2. 软件介绍 2.1 效果图: 2.2 功能介绍 2.2.1 账号登录 页面开始时,会载入这个网站:https://login.taobao.com/member/login ...

  3. C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)

    #include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...

  4. CSS垂直居中的11种实现方式

    今天是邓呆呆球衣退役的日子,在这个颇具纪念意义的日子里我写下自己的第一篇博客,还望前辈们多多提携,多多指教! 接下来,就进入正文,来说说关于垂直居中的事.(以下这11种垂直居中的实现方式均为笔者在日常 ...

  5. C++ 11 多线程--线程管理

    说到多线程编程,那么就不得不提并行和并发,多线程是实现并发(并行)的一种手段.并行是指两个或多个独立的操作同时进行.注意这里是同时进行,区别于并发,在一个时间段内执行多个操作.在单核时代,多个线程是并 ...

  6. CSharpGL(11)用C#直接编写GLSL程序

    CSharpGL(11)用C#直接编写GLSL程序 +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharp ...

  7. ABP(现代ASP.NET样板开发框架)系列之11、ABP领域层——仓储(Repositories)

    点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之11.ABP领域层——仓储(Repositories) ABP是“ASP.NET Boilerplate Proj ...

  8. C++11 shared_ptr 智能指针 的使用,避免内存泄露

    多线程程序经常会遇到在某个线程A创建了一个对象,这个对象需要在线程B使用, 在没有shared_ptr时,因为线程A,B结束时间不确定,即在A或B线程先释放这个对象都有可能造成另一个线程崩溃, 所以为 ...

  9. C++11网络编程

    Handy是一个简洁优雅的C++11网络库,适用于linux与Mac平台.十行代码即可完成一个完整的网络服务器. 下面是echo服务器的代码: #include <handy/handy.h&g ...

随机推荐

  1. java设计模式之门面模式以及在java中作用

    门面模式在Tomcat中有多处使用,在Request和Response对象封装,从ApplicationContext到ServletContext封装中都用到了这种设计模式. 一个系统可以有几个门面 ...

  2. POJ 2182 / HDU 2711 Lost Cows(平衡树)

    Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular di ...

  3. pta指针作业

    #PTA实验作业 6-1 本题pta提交列表 设计思路 本题是一道简单的指针程序题,两个数已经分别被指针定义,只要把用其指针把二者加在一起和减去即可 调试过程 本题无调试过程 代码截图 6-2  1. ...

  4. iOS银联,支付宝,微信,ping++开发文档

    银联支付 银联支付目测只需两个参数 1.tn 其实就是订单号 2.mode 是测试环境还是线上环境 开发步骤 1.首先客户端浏览商品,点击下单,请求到达商户后台 2.商户后台在提交订单信息到银联后台 ...

  5. HL7 2.6 解析(XML)

    用途:检验化验(LIS)实验室设备数据交换解析. using System; using System.Collections.Generic; using System.Text; using Sy ...

  6. 除了基本类型,其余类型基本上大部分new出来 java.sql 包下面要不需要new

    除了基本类型,其余类型基本上大部分new出来 java.sql 包下面要不需要new

  7. python 的sets list dictionary

    http://blog.csdn.net/joseph_happy/article/details/6717412 http://blog.csdn.net/joseph_happy/article/ ...

  8. [洛谷P3946] ことりのおやつ(小鸟的点心)

    题目大意:最短路,第$i$个点原有积雪$h_i$,极限雪高$l_i$(即雪超过极限雪高就不可以行走),每秒降雪$q$,ことり速度为$1m/s$,若时间大于$g$,则输出$wtnap wa kotori ...

  9. [Leetcode] Add two numbers 两数之和

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  10. BZOJ3648 寝室管理 【点分治 + 环套树】

    3648: 寝室管理 Time Limit: 40 Sec  Memory Limit: 512 MB Submit: 366  Solved: 152 [Submit][Status][Discus ...