ASP.NET 사이트에서 멤버 관리를 하려고 폼인증을 사용하였다.

하나의 서버에 3개의 다른 사이트를 한 번의 로그인 정보르 관리하려고 자료를 찾다가 다음과 같은 것을 찾게 되었다.

MSDN 사이트

http://msdn.microsoft.com/ko-kr/library/eb0zx8fc%28v=vs.100%29.aspx

 


<configuration>
  <system.web>
    <authentication mode="Forms" >
      <!-- The name, protection, and path attributes must match 
           exactly in each Web.config file. -->
      <forms loginUrl="login.aspx"
        name=".ASPXFORMSAUTH" 
        protection="All"  
        path="/" 
        domain="contoso.com" 
        timeout="30" />
    </authentication>

    <!-- Validation and decryption keys must exactly match and cannot
         be set to "AutoGenerate". The validation and decryption
         algorithms must also be the same. -->
    <machineKey
      validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" 
      decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" 
      validation="SHA1" />
  </system.web>
</configuration>


그리고 MachineKey 생성하기 위해서는 다음 사이트에서 이용하면 된다.

http://aspnetresources.com/tools/machineKey

Posted by 노을지기

출처: http://imak47.wordpress.com/2011/06/01/the-type-system-io-packaging-package-is-defined-in-an-assembly-that-is-not-referenced-you-must-add-a-reference-to-assembly-windowsbase/

OpenXMLSDKv2 을 설치한 후 샘플 예제를 했는데, 아래와 같은 에러가 발생하였다.

http://code.msdn.microsoft.com/office/CSOpenXmlExportImportExcel-cb196388


The type ‘System.IO.Packaging.Package’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘WindowsBase’

인터넷을 검색하니 "WindowsBase"을 추가하면 된다고 한다.

Add Reference - .NET - WindowsBase



Posted by 노을지기

Bulk Insert sample

File location : C\SampleFolder

MS-SQL: SQL SERVER 2008 R2


데이블 생성한다.

CREATE TABLE [데이터베이스이름].[db_owner].[bulksample](
    [ComputerName] [varchar](50) NULL,
    [Country] [varchar](50) NULL,
    [ip] [varchar](50) NULL,
    [code] [nchar](10) NULL,
    [price] [numeric](18, 0) NULL,
    [no] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
    CONSTRAINT [PK_bulksample] PRIMARY KEY CLUSTERED ( [no] ASC )
) ON [PRIMARY] 


Data File (Comma delimited CSV) - sample.csv

ComputerName Country IP Code Price No
Com1 CANADA 192.168.1.1 0E1 2000  
Com2 CANADA 192.168.1.2 0E2 2001  
Com3 CANADA 192.168.1.3 0E3 2002  
Com4 CANADA 192.168.1.4 0E4 2003  
Com5 CANADA 192.168.1.5 0E5 2004  
Com6 CANADA 192.168.1.6 0E6 2005  
Com7 CANADA 192.168.1.7 0E7 2006  
Com8 CANADA 192.168.1.8 0E8 2007  
Com9 CANADA 192.168.1.9 0E9 2008  
Com10 CANADA 192.168.1.10 0E10 2009  
Com11 CANADA 192.168.1.11 0E11 2010  
Com12 CANADA 192.168.1.12 0E12 2011  
Com13 CANADA 192.168.1.13 0E13 2012  
Com14 CANADA 192.168.1.14 0E14 2013  
Com15 CANADA 192.168.1.15 0E15 2014  
Com16 CANADA 192.168.1.16 0E16 2015  
Com17 CANADA 192.168.1.17 0E17 2016  


위의 샘플 데이터를 양식 없이 바로 입력했을 경우.. 데이터가 깨진다.

(Microsoft SQL Server management Studio에서는 제대로 입력됨.. 하지만 프로그램을 이용하면 다름과 같이 보인다.


BULK INSERT [데이터베이스이름].[db_owner].[bulksample]
FROM 'C:\SampleFolder\sample.csv'
WITH
(
    FIELDTERMINATOR=',',
    ROWTERMINATOR = '\n',
    FIRSTROW = 2
)
Go


ComputerName    Country    ip    code    price    no
Com1    CANADA    192.168.1.1    0.00E+00   2000    77
Com2    CANADA    192.168.1.2    0.00E+00   2001    78
Com3    CANADA    192.168.1.3    0.00E+00   2002    79
Com4    CANADA    192.168.1.4    0.00E+00   2003    80
Com5    CANADA    192.168.1.5    0.00E+00   2004    81
Com6    CANADA    192.168.1.6    0.00E+00   2005    82
Com7    CANADA    192.168.1.7    0.00E+00   2006    83
Com8    CANADA    192.168.1.8    0.00E+00   2007    84
Com9    CANADA    192.168.1.9    0.00E+00   2008    85
Com10    CANADA    192.168.1.10    0.00E+00   2009    86
Com11    CANADA    192.168.1.11    0.00E+00   2010    87
Com12    CANADA    192.168.1.12    0.00E+00   2011    88
Com13    CANADA    192.168.1.13    0.00E+00   2012    89
Com14    CANADA    192.168.1.14    0.00E+00   2013    90
Com15    CANADA    192.168.1.15    0.00E+00   2014    91
Com16    CANADA    192.168.1.16    0.00E+00   2015    92
Com17    CANADA    192.168.1.17    0.00E+00   2016    93


그래서 포맷을 이용하여 code 부분을 수정해야한다.

C:> CD \

C:> CD SampleFolder

c:\SampleFolder>bcp "[데이터베이스이름].db_ownder.bulksample" out "c:\SampleFolder\a.txt" -U[데이터베이스 유저 이름]

password:

나중에 변경할 예정이르모 무조건 enter

Enter the file storage type of field ComputerName [char]: Enter prefix-length of
 field ComputerName [2]:
Enter field terminator [none]:

Enter the file storage type of field Country [char]:
Enter prefix-length of field Country [2]:
Enter field terminator [none]:

Enter the file storage type of field ip [char]:
Enter prefix-length of field ip [2]:
Enter field terminator [none]:

Enter the file storage type of field code [nchar]:
Enter prefix-length of field code [2]:
Enter field terminator [none]:

Enter the file storage type of field price [numeric]:
Enter prefix-length of field price [1]:
Enter field terminator [none]:

Enter the file storage type of field no [numeric]:
Enter prefix-length of field no [1]:
Enter field terminator [none]:

Do you want to save this format information in a file? [Y/n]
Host filename [bcp.fmt]:

Starting copy...

17 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total     : 1      Average : (17000.00 rows per sec.)

C:\SampleFolder>
C:\SampleFolder>


그후 C:\Samplefolder에 bcp.fmt 파일이 보인다.

이 파일을 sample.fmt로 복사한다.

메모장에서 열어보면 다음과 같다.

10.0
6
1       SQLCHAR             2       50      ""   1     ComputerName                 SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR             2       50      ""   2     Country                      SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR             2       50      ""   3     ip                           SQL_Latin1_General_CP1_CI_AS
4       SQLNCHAR            2       20      ""   4     code                         SQL_Latin1_General_CP1_CI_AS
5       SQLNUMERIC          1       19      ""   5     price                        ""
6       SQLNUMERIC          1       19      ""   6     no                           ""

이것을 다음과 같이 변경하고 실행할 경우 에러가 발생한다.

sample.fmt

10.0
6
1       SQLCHAR             0       50      ","   1     ComputerName                 SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR             0       50      ","   2     Country                      SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR             0       50      ","   3     ip                           SQL_Latin1_General_CP1_CI_AS
4       SQLNCHAR            0       20      ","   4     code                         SQL_Latin1_General_CP1_CI_AS
5       SQLNUMERIC          0       19      ","   5     price                        ""
6       SQLNUMERIC          0       19      "\r\n"   6     no                           ""

다음과 같이 명령어 입력..

 BULK INSERT [데이터베이스이름].[db_owner].[bulksample]
FROM 'C:\SampleFolder\sample.csv'
WITH (
    FORMATFILE = 'C:\SampleFolder\sample.fmt',
    FIRSTROW = 2
)

에러 메시지

Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 2, column 4 (code).
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".


이것 때문에 고생을 많이 했다.ㅡㅡ;;

sample.fmt 을 다음과 같이 변경한다.

10.0
6
1       SQLCHAR             0       50      ","   1     ComputerName                 SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR             0       50      ","   2     Country                      SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR             0       50      ","   3     ip                           SQL_Latin1_General_CP1_CI_AS
4       SQLCHAR             0       20      ","   4     code                         SQL_Latin1_General_CP1_CI_AS
5       SQLCHAR             0       19      ","   5     price                        ""
6       SQLCHAR             0       19      "\r\n"   6     no                           ""


데이터가 정상적으로 입력된다.

Computer Name    Country    ip    code    price    no
Com1    CANADA    192.168.1.1    0E1           2000    94
Com2    CANADA    192.168.1.2    0E2           2001    95
Com3    CANADA    192.168.1.3    0E3           2002    96
Com4    CANADA    192.168.1.4    0E4           2003    97
Com5    CANADA    192.168.1.5    0E5           2004    98
Com6    CANADA    192.168.1.6    0E6           2005    99
Com7    CANADA    192.168.1.7    0E7           2006    100
Com8    CANADA    192.168.1.8    0E8           2007    101
Com9    CANADA    192.168.1.9    0E9           2008    102
Com10    CANADA    192.168.1.10    0E10          2009    103
Com11    CANADA    192.168.1.11    0E11          2010    104
Com12    CANADA    192.168.1.12    0E12          2011    105
Com13    CANADA    192.168.1.13    0E13          2012    106
Com14    CANADA    192.168.1.14    0E14          2013    107
Com15    CANADA    192.168.1.15    0E15          2014    108
Com16    CANADA    192.168.1.16    0E16          2015    109
Com17    CANADA    192.168.1.17    0E17          2016    110

다음에 ASP.NET이나 C#의 어플리케이션에서 작업 후 결과를 확인해야겠다.


아직까지는 보류중..




Posted by 노을지기

대용량 데이터를 입력할 일 있어서 bulk insert로 입력하였다.

데이터가 많을 경우 아주 유용하게 사용하였다.


하지만 문제는 입력시 자동으로 포맷이 변경되는 경우이다.

예를 들어 ip나 0으로 시작하는 데이터는 자기 마음대로 포맷을 변경하였다.

ex) 0E1 -> 0x0000xxx

그래서 포맷을 지정하기 위해서 Format file을 이용하려고 하는데... 

[Host file datatype]에서 문제가 발행하였다.

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.utility/html/utility/utility86.htm

Storage format에서 numeric 포맷을 SYBNUMERIC로 변경하여 넣으면 바로 에러가 발생한다.


그래서 방법을 찾던 중 다음 것을 발견하였다.

http://msdn.microsoft.com/en-us/library/ms191175.aspx

Using a Non-XML Format File


You can change the order of a column mapping by changing the order value for the column to indicate the position of the corresponding data field.

The following sample non-XML format file presents a format file, myTestOrder.fmt, that maps the fields in myTestOrder-c.txt to the columns of the myTestOrder table. For information about how to create the data file and table, see "Sample Table and Data File," earlier in this topic. The format file uses character data format.

The format file contains the following information:

          9.0
4
1       SQLCHAR       0       100     ","     3     Col3               SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR       0       100     ","     2     Col2               SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR       0       7       ","     1     Col1               ""
4       SQLCHAR       0       100     "\r\n"  4     Col4               SQL_Latin1_General_CP1_CI_AS

        

위에 같이 Col1 컬럼이 숫자형인데, SYBNUMERIC을 사용하지 않고, 바로 SQLCHAR을 사용하였다.

그후에 입력하니 바로 성공..ㅡㅡ;;

왜 이러는지는 나도 모름..ㅠㅠ

다음 페이지 예제로 확인 <-- 나중에 잊어 먹지 않기 위해서..



Posted by 노을지기

Visual Studio 2008

References 에서 추가

- Right button Click on References

- Click "Add Reference.."

- Find "CrystalDecisions.Web" in .Net tab

Posted by 노을지기
이전버튼 1 2 3 4 5 6 7 ··· 20 이전버튼