는C#에서 데이터 테이블의 숫자 필드에 null 값을 삽입하는 방법은 무엇입니까?
Id Name Mob1 Mob2
1 acp 9994564564 9568848526
, 내 동적으로 생성 된 데이터 테이블은 다음 fileds Id,Name,Mob1,Mob2
내 데이터 테이블이 성공적으로 삽입이되어있는 경우를 포함 고려하지만이 같은 경우는, 말을 실패됩니다
Id Name Mob1 Mob2
1 acp 9994564564
The given value of type String from the data source cannot be converted to type decimal of the specified target column.
나는 내 데이터 테이블을 r CSV 파일을 eadingt
CSVReader reader = new CSVReader(CSVFile.PostedFile.InputStream);
string[] headers = reader.GetCSVLine();
DataTable dt = new DataTable();
foreach (string strHeader in headers)
{
dt.Columns.Add(strHeader);
}
string[] data;
while ((data = reader.GetCSVLine()) != null)
{
dt.Rows.Add(data);
}
C#에서 대량 복사시 숫자 필드에 null 값을 삽입하는 방법을 어떤 제안
...편집 :
나는이 dt.Columns["Mob2"].AllowDBNull = true;
을 시도했지만 그렇지 않은 작동하는 것 같습니다 ...
시도 NULL 값을 허용하도록 설정된 열 속성입니까? 데이터베이스에있는 열의 데이터 형식은 무엇입니까? –
@ranhiru 나중에 거기에'MobileNo2 (numeric (18,0), null)'... –
전화 번호를 숫자로 저장하는 것은 나쁜 생각이다. –