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


C# SqlConnection.CloseConnection方法代码示例

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


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

示例1: Run


//.........这里部分代码省略.........
                                    {
                                        //Logging.PushInfo(query);
                                        command.ExecuteNonQuery();
                                    }
                                }
                            }
                            else if (createStatus == MembershipCreateStatus.DuplicateEmail ||
                                     createStatus == MembershipCreateStatus.DuplicateUserName)
                            {
                                //listEmailDuplicate.Add("'" + userAdapt.Email + "'");
                            }
                        }
                    }
                }

                if (desConn.State == ConnectionState.Open)
                {
                    desConn.Close();
                    desConn.Dispose();
                }

                //insert query to queue table


                Logging.PushInfo("===============Start Insert Query To Queue Table===================");

                Logging.PushInfo("Enable identity insert on table [SysproMigration].[dbo].[QueueMigrate]");

                var migrationConn1 = MigrationConnectionString.CreateAndOpenConnection("Syspro Migration");

                var enableIdentityInsert = new SqlCommand("SET IDENTITY_INSERT [SysproMigration].[dbo].[QueueMigrate] ON", migrationConn1);
                enableIdentityInsert.ExecuteNonQuery();

                migrationConn1.CloseConnection();

                foreach (var fieldsMap in FieldsMaps)
                {
                    InsertQueryToQueue(fieldsMap, MigrationConnectionString);
                }

                Logging.PushInfo("===============End Insert Query To Queue Table===================");

                Logging.PushInfo("===============Start Read Query from Query Table===================");

                var migrationConn = MigrationConnectionString.CreateAndOpenConnection("Syspro Migration");

                var sourceConnObject = SourceConnectionString.GetObjectConnection();
                var desConnObject = DestinationConnectionString.GetObjectConnection();

                var objectQueue = new QueueMigrate
                {
                    SourceServerName = sourceConnObject.DataSource,
                    SourceDatabaseCompany = sourceConnObject.InitialCatalog,

                    TargetServerName = desConnObject.DataSource,
                    TargetDatabaseCompany = desConnObject.InitialCatalog
                };

                var lstQueue = Utils.GetQueueMigrates(migrationConn, objectQueue);

                migrationConn.CloseConnection();

                foreach (var queue in lstQueue)
                {
                    var fieldmap = FieldsMaps.FirstOrDefault(t => t.Id == queue.FieldsMapId);
                    MigrateFromQueue(queue, fieldmap);
开发者ID:tuanvn6467,项目名称:SysproMigration,代码行数:67,代码来源:MigratorModel.cs


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