• 大小: 74KB
    文件类型: .zip
    金币: 2
    下载: 2 次
    发布日期: 2021-12-10
  • 语言: C#
  • 标签: SQL  

资源简介

http: blog csdn net yangzhenping article details 40424585 1 C#同步SQL Server数据库中的数据 数据库同步工具[同步已有的有变化的数据] 2 分析下自己写的SQL Server同步工具的性能和缺陷 3 C#同步SQL Server数据库中的数据 数据库同步工具[同步新数据] 4 C#同步SQL Server数据库Schema">http: blog csdn net yangzhenping article details 40424585 1 C#同步SQL Server数据库中的数据 数据库同步工具[同步已有的有变化的数据] 2 分析下自己写的SQL Server同步工具的性能和缺陷 3 C#同步SQL Server数据库中的数据 数据库同 [更多]

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace PinkDatabaseSync
{
    class DBUtility : IDisposable
    {
        private string Server;
        private string Database;
        private string Uid;
        private string Password;
        private string connectionStr;
        private SqlConnection mySqlConn;

        public void EnsureConnectionIsOpen()
        {
            if (mySqlConn == null)
            {
                mySqlConn = new SqlConnection(this.connectionStr);
                mySqlConn.Open();
            }
            else if (mySqlConn.State == ConnectionState.Closed)
            {
                mySqlConn.Open();
            }
        }

        public DBUtility(string server string database string uid string password)
        {
            this.Server = server;
            this.Database = database;
            this.Uid = uid;
            this.Password = password;
            this.connectionStr = “Server=“ + this.Server + “;Database=“ + this.Database + “;User Id=“ + this.Uid + “;Password=“ + this.Password;
        }

        public int ExecuteNonQueryForMultiplescripts(string sqlStr)
        {
            this.EnsureConnectionIsOpen();
            SqlCommand cmd = mySqlConn.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = sqlStr;
            return cmd.ExecuteNonQuery();
        }
        public int ExecuteNonQuery(string sqlStr)
        {
            this.EnsureConnectionIsOpen();
            SqlCommand cmd = new SqlCommand(sqlStr mySqlConn);
            cmd.CommandType = CommandType.Text;
            return cmd.ExecuteNonQuery();
        }


        public object ExecuteScalar(string sqlStr)
        {
            this.EnsureConnectionIsOpen();
            SqlCommand cmd = new SqlCommand(sqlStr mySqlConn);
            cmd.CommandType = CommandType.Text;
            return cmd.ExecuteScalar();
        }

        public DataSet ExecuteDS(string sqlStr)
        {
            DataSet ds = new DataSet();
            this.EnsureConnectionIsOpen();
            SqlDataAdapter sda = new SqlDataAdapter(sqlStr mySqlConn);
            sda.Fill(ds);
            return ds;
        }

        public void BulkCopyTo(string server string database string uid string password string tableName string primaryKeyName)
        {
            string connectionString = “Server=“ + server + “;Database=“ + database + “;User Id=“ + uid + “;Password=“ + password;
            // Create destination connection
            SqlConnection destinationConnector = new SqlConnection(connectionString);

            SqlCommand cmd = new SqlCommand(“SELECT * FROM “ + tableName destinationConnector);
            // Open source and destination connections.
            this.EnsureConnectionIsOpen();
            destinationConnector.Open();

            S

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1017  2014-10-23 15:33  PinkDatabaseSync\PinkDatabaseSync.sln
     文件       35840  2014-10-27 14:33  PinkDatabaseSync\PinkDatabaseSync.v12.suo
     目录           0  2014-10-24 11:04  PinkDatabaseSync\PinkDatabaseSync\
     目录           0  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\bin\
     目录           0  2014-10-21 15:16  PinkDatabaseSync\PinkDatabaseSync\bin\Debug\
     文件       20480  2014-10-23 17:42  PinkDatabaseSync\PinkDatabaseSync\bin\Debug\PinkDatabaseSync.exe
     文件       42496  2014-10-23 17:42  PinkDatabaseSync\PinkDatabaseSync\bin\Debug\PinkDatabaseSync.pdb
     文件       22704  2014-10-23 17:43  PinkDatabaseSync\PinkDatabaseSync\bin\Debug\PinkDatabaseSync.vshost.exe
     文件         490  2012-06-02 22:34  PinkDatabaseSync\PinkDatabaseSync\bin\Debug\PinkDatabaseSync.vshost.exe.manifest
     文件       11389  2014-10-24 11:04  PinkDatabaseSync\PinkDatabaseSync\DBUtility.cs
     文件        8682  2014-10-23 17:02  PinkDatabaseSync\PinkDatabaseSync\Form1.cs
     文件        2675  2014-10-23 09:57  PinkDatabaseSync\PinkDatabaseSync\Form1.Designer.cs
     文件        5817  2014-10-23 09:57  PinkDatabaseSync\PinkDatabaseSync\Form1.resx
     目录           0  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\obj\
     目录           0  2014-10-23 17:42  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\
     文件         791  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6025  2014-10-22 09:37  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         661  2014-10-23 17:43  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.csproj.FileListAbsolute.txt
     文件         847  2014-10-23 09:58  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.csproj.GenerateResource.Cache
     文件        1341  2014-10-21 15:15  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.csprojResolveAssemblyReference.cache
     文件       20480  2014-10-23 17:42  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.exe
     文件       42496  2014-10-23 17:42  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.pdb
     文件         180  2014-10-23 09:58  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.PinkDatabaseSync.resources
     文件         180  2014-10-22 09:49  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\PinkDatabaseSync.Properties.Resources.resources
     目录           0  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\obj\Debug\TempPE\
     文件        3641  2014-10-22 09:48  PinkDatabaseSync\PinkDatabaseSync\PinkDatabaseSync.csproj
     文件         499  2014-10-21 14:47  PinkDatabaseSync\PinkDatabaseSync\Program.cs
     目录           0  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\Properties\
     文件        1444  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\Properties\AssemblyInfo.cs
     文件        2862  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\Properties\Resources.Designer.cs
     文件        5612  2014-10-21 14:46  PinkDatabaseSync\PinkDatabaseSync\Properties\Resources.resx
............此处省略3个文件信息

评论

共有 条评论