How can I improve this code please?
It sometimes produces this error:
"Object reference not set to an instance of an object"
When I do this:
strSQL = "UPDATE TBL_Items SET" & _
" item_itemnumber = " & PrepareStr(Label6.Text) & _
" ,item_itemcurrentbidprice = " &
PrepareStr(itemCurrentbidprice) & _
" ,item_itembidhistory = " &
PrepareStr(itembidHistory) & _
" ,item_itemcurrentorpurchasedbidder = " &
PrepareStr(itemCurrentorpurchasedbidder) & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '" & Label6.Text & "'"
Here is the code:
Private Function PrepareStr(ByVal strValue As String) As String
' This function accepts a string and creates a string that can
' be used in a SQL statement by adding single quotes around
' it and handling empty values.
If strValue.Trim() = "" Then
Return "NULL"
Else
Return "'" & strValue.Trim() & "'"
End If
End Function
Thanks,
Trint
.Net programmer
tr********@hotmail.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!