OleDbDataAdapter具体使用11
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的更多相关文章
- 地区sql
/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...
- WinForm 天猫2013双11自动抢红包【源码下载】
1. 正确获取红包流程 2. 软件介绍 2.1 效果图: 2.2 功能介绍 2.2.1 账号登录 页面开始时,会载入这个网站:https://login.taobao.com/member/login ...
- C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)
#include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...
- CSS垂直居中的11种实现方式
今天是邓呆呆球衣退役的日子,在这个颇具纪念意义的日子里我写下自己的第一篇博客,还望前辈们多多提携,多多指教! 接下来,就进入正文,来说说关于垂直居中的事.(以下这11种垂直居中的实现方式均为笔者在日常 ...
- C++ 11 多线程--线程管理
说到多线程编程,那么就不得不提并行和并发,多线程是实现并发(并行)的一种手段.并行是指两个或多个独立的操作同时进行.注意这里是同时进行,区别于并发,在一个时间段内执行多个操作.在单核时代,多个线程是并 ...
- CSharpGL(11)用C#直接编写GLSL程序
CSharpGL(11)用C#直接编写GLSL程序 +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharp ...
- ABP(现代ASP.NET样板开发框架)系列之11、ABP领域层——仓储(Repositories)
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之11.ABP领域层——仓储(Repositories) ABP是“ASP.NET Boilerplate Proj ...
- C++11 shared_ptr 智能指针 的使用,避免内存泄露
多线程程序经常会遇到在某个线程A创建了一个对象,这个对象需要在线程B使用, 在没有shared_ptr时,因为线程A,B结束时间不确定,即在A或B线程先释放这个对象都有可能造成另一个线程崩溃, 所以为 ...
- C++11网络编程
Handy是一个简洁优雅的C++11网络库,适用于linux与Mac平台.十行代码即可完成一个完整的网络服务器. 下面是echo服务器的代码: #include <handy/handy.h&g ...
随机推荐
- BZOJ 1923 SDOI2010 外星千足虫 异或方程组+bitset
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1923 懒得贴题目了......这就是解一个异或方程组的裸题...... YY了一下异或方程 ...
- Java空指针异常解决方法
Throwable是所有错误或异常的超类,只有当对象是这个类的实例时才能通过Java虚拟机或者Java throw语句抛出. 当Java运行环境发出异常时,会寻找处理该异常的catch块,找到对应的c ...
- React & styled component
React & styled component https://www.styled-components.com/#your-first-styled-component tagged t ...
- hdu 1267 下沙的沙子有几粒? (递推)
下沙的沙子有几粒? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- ARC075 F.Mirrored
题目大意:给定D,询问有多少个数,它的翻转减去它本身等于D 题解做法很无脑,利用的是2^(L/2)的dfs,妥妥超时 于是找到了一种神奇的做法. #include <iostream> u ...
- FFT多项式乘法模板
有时间来补算法原理orz #include <iostream> #include <cstdio> #include <cmath> #include <c ...
- [洛谷P1337][JSOI2004]平衡点 / 吊打XXX
题目大意:有$n$个重物,每个重物系在一条绳子上.所有绳子系在一起,问绳结最终平衡于何处. 题解:$NOIP$前学学模拟退火,但发现我脸好黑啊... 卡点:脸黑 C++ Code: #include ...
- Linux产生背景
By francis_hao Oct 26,2016 很久很久以前,大概在1965年左右,由贝尔实验室(Bell).麻省理工学院(MIT)及通用电气公司(GE)共同发起了一个叫做Multics的项目, ...
- oracle与mysql与sqlserver的分页
假设当前是第PageNo页,每页有PageSize条记录,现在分别用Mysql.Oracle和SQL Server分页查询student表. 1.Mysql的分页查询: 1 SELECT 2 * 3 ...
- -webkit-overflow-scrolling:touch;
-webkit-overflow-scrolling建了带有硬件加速的系统级控件,所以效率很高.但是这相对是耗更多内存的,最好在产生了非常大面积的overflow时才应用. 而且在 ios8 里有b ...