当前位置: 首页>>代码示例>>C#>>正文


C# DbConnection.pullData方法代码示例

本文整理汇总了C#中DbConnection.pullData方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnection.pullData方法的具体用法?C# DbConnection.pullData怎么用?C# DbConnection.pullData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbConnection的用法示例。


在下文中一共展示了DbConnection.pullData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoJob

        public override void DoJob()
        {
            StringBuilder sb = new StringBuilder(); // Result of the query.

            sb.AppendFormat("JobType: {0}", GetName()).AppendLine();
            
            /*
             * TODO: Properly read in connection information here.
             */
            DbConnectorInfo sourceInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "NORTHWND", "sa", "Conestoga1");
            DbConnection sourceConnection = new DbConnection(sourceInfo, "MS");

            Dictionary<string, string> keys = new Dictionary<string, string>();
            keys.Add("Customers", "CustomerID");
            keys.Add("Orders", "OrderID");

            List<string> joins = new List<string>();
            joins.Add("full");

            sb.Append("Connecting to source...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", sourceInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", sourceInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", sourceInfo.userid).AppendLine();

            /*
             * Open the source and destination databases.
             */
            if (!sourceConnection.ConnectionOpen)
            {
                sourceConnection.OpenDBConnection();
            }

            /*
             * Pull data from BioLinks.
             * TODO: Figure out wtf this method even takes.
             */
            DataTable sourceData = sourceConnection.pullData(keys, joins, null, null);

            /*
             * Log the query.
             */
            foreach (DataRow row in sourceData.Rows)
            {
                foreach (DataColumn col in sourceData.Columns)
                {
                    sb.AppendFormat("{0} ", row[col]);    
                }

                sb.AppendLine();
            }

            Logger.logMessage(sb.ToString(), AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath + "\\Events2.txt");

            /*
             * Close the source and destination databases.
             */
            sourceConnection.CloseDBConnection();
        }
开发者ID:aschryvercc,项目名称:Project-BIO,代码行数:59,代码来源:SingleJob.cs

示例2: DoJob

        public override void DoJob()
        {
            const string ID_COLUMN_NAME = "EmployeeID";
            const string TABLE_NAME = "Employees";

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("JobType: {0}", GetName()).AppendLine();

            /*
             * TODO: Properly read in connection information here.
             */
            DbConnectorInfo sourceInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "NORTHWND", "sa", "Conestoga1");
            destinationInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "SimpleNorthwind", "sa", "Conestoga1");

            DbConnection sourceConnection = new DbConnection(sourceInfo, "MS");
            DbConnection destinationConnection = new DbConnection(destinationInfo, "MS");

            /*
             * Build the query for updating from the table.
             */
            //List<string> columns_to_pull = new List<string>();
            //columns_to_pull.Add(ROW_KEY);
            //columns_to_pull.Add(ROW_NAME);
            //columns_to_pull.Add(TABLE_NAME);
            List<string> where_clauses = new List<string>();
            /*
             * Some janky stuff to get this working.
             */
            where_clauses.Add(ID_COLUMN_NAME + " = " + i);
            ++i;

            sb.Append("Connecting to source...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", sourceInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", sourceInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", sourceInfo.userid).AppendLine();

            sb.Append("Connecting to destination...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", destinationInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", destinationInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", destinationInfo.userid).AppendLine();

            /*
             * Open the source and destination databases.
             */
            if (!sourceConnection.ConnectionOpen)
            {
                sourceConnection.OpenDBConnection();
            }
            if (!destinationConnection.ConnectionOpen)
            {
                destinationConnection.OpenDBConnection();
            }

            /*
             * Pull data from BioLinks.
             * TODO: Figure out wtf this method even takes.
             */
            DataTable sourceData = sourceConnection.pullData(TABLE_NAME, null, where_clauses);

            sb.AppendLine("Source Data: ");

            foreach (DataRow row in sourceData.Rows)
            {
                sb.AppendLine(sourceData.Rows.IndexOf(row).ToString());
            }

            /*
             * Insert/Update pulled into BioTrack.
             */
            destinationConnection.insert(TABLE_NAME, sourceData);

     
            destinationConnection.insert(TABLE_NAME, sourceData);

            Logger.logMessage(sb.ToString(), AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath + "\\Events.txt");

            /*
             * Close the source and destination databases.
             */
            sourceConnection.CloseDBConnection();
            destinationConnection.CloseDBConnection();
        }
开发者ID:aschryvercc,项目名称:Project-BIO,代码行数:85,代码来源:RepeatableJob.cs


注:本文中的DbConnection.pullData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。