Unanswered: help needed with building SQL statement
Is it required to have quotes around field values while doing insert/update/delete?
INSERT INTO t_customer (cust_cde, cust_name, m_ind, start_dte, lst_upd_id) VALUES ('452','Tata Young','S','2/4/2005','sResh12')
I receive following err msg if there's no quotes around field values (in this case if there's no quotes around lst_upd_id):
The name 'sResh12' is illegal in this context.
Only constants, constant expressions, or variables allowed here. Column names are illegal
In the following program, when I try to put aposhtrophe in dr("m_ind") field which is char(1), get error when datarow is added to ds.tables(0).rows.add(dr),
Cannot set column 'nmdp_ind' to "N".
The value violates the MaxLength limit of this column.
Also, none of the date fields gets apostrophes.
Is there way around this problem?
If IsNew Then
Public Function PrepareStr(ByVal strValue As String) As String
If InStr(strValue.Trim(), "'") Then
Dim ReplacedValue As String = Replace(strValue.Trim(), "'", "''")
Return "'" & ReplacedValue.Trim() & "'"
Else : Return "'" & strValue.Trim() & "'"