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(Labe l6.Text) & _
" ,item_itemcurre ntbidprice = " &
PrepareStr(item Currentbidprice ) & _
" ,item_itembidhi story = " &
PrepareStr(item bidHistory) & _
" ,item_itemcurre ntorpurchasedbi dder = " &
PrepareStr(item Currentorpurcha sedbidder) & _
"FROM TBL_Items " & _
"WHERE item_itemnumber = '" & Label6.Text & "'"
Here is the code:
Private Function PrepareStr(ByVa l 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********@hotm ail.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!