Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
dreader4.cs
Package: Visual.rar [view]
Upload User: yiyuerguo
Upload Date: 2014-09-27
Package Size: 3781k
Code Size: 2k
Category:
CSharp
Development Platform:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- namespace RowOperationApp
- {
- /// <summary>
- /// Class1 的摘要说明。
- /// </summary>
- class RowOperation
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SimpleBank.mdb");
- connection.Open();
- OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Account",connection);
- OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
- DataSet dataset = new DataSet();
- // adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- adapter.Fill(dataset,"Account");
- Console.WriteLine("rows before change:{0}",dataset.Tables["Account"].Rows.Count);
- DataColumn[] keys = new DataColumn[2];
- keys[0] = dataset.Tables["Account"].Columns["AccountID"];
- keys[1] = dataset.Tables["Account"].Columns["Owner"];
- dataset.Tables["Account"].PrimaryKey = keys;
- string[] name = {"333","jin2"};
- DataRow findRow = dataset.Tables["Account"].Rows.Find(name);
- if (findRow == null)
- {
- Console.WriteLine("Row {0} {1} don't exist, add it to Employees table",name[0],name[1]);
- DataRow newRow = dataset.Tables["Account"].NewRow();
- newRow["AccountID"] = name[0];
- newRow["Owner"] = name[1];
- dataset.Tables["Account"].Rows.Add(newRow);
- Console.WriteLine("Row {0} {1} successfully added it into Account table",name[0],name[1]);
- }
- else
- {
- Console.WriteLine("Row {0} {1} already exist in Account table",name[0],name[1]);
- }
- adapter.Update(dataset,"Account");
- connection.Close();
- Console.ReadLine();
- }
- }
- }