purplehaze1
Programmer
how to handle null values while doing insert/update? here's my problem, the following SQL fails:
INSERT INTO t_customer (cust_cde, cust_name, m_ind, start_dte, lst_upd_id)
VALUES (,'Tata Young','','2/4/2005','sResh12')
db design:
cust_cde is smallint type in db that allows null.
cust_ind is char(1)
program creating SQL:
For Each aColumn In aTable.Columns
If (aColumn.Unique) Then
strSQLWhere = String.Format(" WHERE {0} = {1}", _
aColumn.ColumnName, aDataRow(aColumn))
ElseIf (aColumn.DataType Is System.Type.GetType("System.String")) Then
strSQL &= String.Format(" {0} = '{1}'", _
aColumn.ColumnName, aDataRow(aColumn))
Else
strSQL &= String.Format(" {0} = {1}", _
aColumn.ColumnName, aDataRow(aColumn))
End If
If (aCounter < aColumnCount) Then
strSQL &= ", "
End If
aCounter += 1
Next
Thanks,
INSERT INTO t_customer (cust_cde, cust_name, m_ind, start_dte, lst_upd_id)
VALUES (,'Tata Young','','2/4/2005','sResh12')
db design:
cust_cde is smallint type in db that allows null.
cust_ind is char(1)
program creating SQL:
For Each aColumn In aTable.Columns
If (aColumn.Unique) Then
strSQLWhere = String.Format(" WHERE {0} = {1}", _
aColumn.ColumnName, aDataRow(aColumn))
ElseIf (aColumn.DataType Is System.Type.GetType("System.String")) Then
strSQL &= String.Format(" {0} = '{1}'", _
aColumn.ColumnName, aDataRow(aColumn))
Else
strSQL &= String.Format(" {0} = {1}", _
aColumn.ColumnName, aDataRow(aColumn))
End If
If (aCounter < aColumnCount) Then
strSQL &= ", "
End If
aCounter += 1
Next
Thanks,