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]);         }     } }

最新文章

  1. 二模 (13)day2
  2. 黄聪:C#操作Word表格的常见操作(转)
  3. Spring 依赖注入的方式
  4. 大型网站系统架构演化之路【mark】
  5. Java Collections Source Code Series 1 --- 简介
  6. 宠物AI(个人觉得有问题)
  7. Windows 之 CMD命令
  8. yii2单独给input或者其他标签定义class
  9. uva 1030 - Image Is Everything(迭代更新)
  10. memcache 操作类
  11. Linux服务器SNMP常用OID (转)
  12. 针对IE的CSS样式hack
  13. 扩展entity framework core 实现默认字符串长度,decimal精度,entity自动注册和配置
  14. Java线程面试题
  15. Python 基础【二】 下
  16. ES6 迭代器和生成器
  17. [tldk][dpdk][dev] TLDK--基于dpdk的用户态协议栈传输层组件简单调研
  18. SpringMVC中@RestController的用法
  19. 【Linux】find命令
  20. C++:sprintf()的用法(转)

热门文章

  1. Android Studio环境解读
  2. 基于JWT的无状态分布式授权【本文摘自智车芯官网】
  3. CSS position属性---absolute与relative
  4. 使用 window.getSelection() 方法获取鼠标划取部分的起始位置和结束位置的问题(高亮后不能正确获取)
  5. Hangman游戏源代码 --- python实现
  6. 【AtCoder ARC076】F Exhausted? 霍尔定理+线段树
  7. Antlr 在 idea 中正确使用的方式
  8. [BZOJ1921] [CTSC2010]珠宝商
  9. [CF327E]Axis Walking([洛谷P2396]yyy loves Maths VII)
  10. jocky1.0.3 (原joc) java混淆器 去除jdk版本限制