Binary 데이터값을가진 String변수값 SQL Binabary 필드에 Insert - C#
프로그램/c# fundamental 2009. 2. 25. 17:30 |.aspx.cs
strEvtComID = "0x0000000000000034";
Biz.매서드(int.Parse( strEvtComID.Replace( "0x", "" ), NumberStyles.HexNumber )) // int.Parse로 형변환
.Biz.cs
public int put_WB_Consult_Product(int _TY_EventCompany_ID)
{
SqlParameter[] p = new SqlParameter[0];
try
{
p[0] = new SqlParameter( "@TY_WB_Customer_Consult_Id" , SqlDbType.BigInt);
p[0].Value = _PK;
return this.DbAccess.RunSPNonQuery( "SP_WB_Event_Consult_INSERT", Site.GetReplace(p) );
}
catch ( Exception ex )
{
this.TraceWrite( System.Diagnostics.TraceLevel.Error, ex.Message ); // 에러를 로그파일에 입력
return 0;
}
}
SP
CREATE PROCEDURE SP_WB_Event_Consult_INSERT
@TY_WB_Customer_Consult_Id BINARY(8)
Table
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TY_WB_Customer_Consult]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TY_WB_Customer_Consult]
GO
CREATE TABLE [dbo].[TY_WB_Customer_Consult] (
[Contact_Id] [binary] (8) NULL ,
[C_idx] [int] NULL ,
[Product_Id] [binary] (8) NULL ,
[Product_Name] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL ,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO