SqlBulkCopy 상세 사용

1044 단어 C#
    string connection = "      ";
            using (SqlConnection sqlconn = new SqlConnection(connection))
            {
                sqlconn.Open();
                try
                {
                    using (SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(sqlconn))
                    {
                        //         
                        SqlBulkCopyColumnMapping sm1 = new SqlBulkCopyColumnMapping("Name", "Name");
                        SqlBulkCopyColumnMapping sm2 = new SqlBulkCopyColumnMapping("ID", "ID");
                        sqlbulkcopy.ColumnMappings.Add(sm1);
                        sqlbulkcopy.ColumnMappings.Add(sm2);
                       //          
                        sqlbulkcopy.DestinationTableName = "S";
                       //       
                        sqlbulkcopy.WriteToServer(ble);
                    }
                }
                catch (Exception ex)
                {
                }
            }

좋은 웹페이지 즐겨찾기