I am rewriting this long INSERT statement and parameters used to look like this:
cmd.Parameters.AddWithValue("@Website", General.fnSQLNullValues(tWebsite.Text))
Where General.fnSQLNullValues is this:
Public Shared Function fnSQLNullValues(ByVal sValue As Object, Optional ByVal Len As Integer = 999999) As Object
If sValue Is Nothing Then Return DBNull.Value
fnSQLNullValues = IIf(sValue.ToString.Length = 0, DBNull.Value, Left(sValue.ToString(), Len))
End Function
I don't like this at all , and it seems to be alot of code all to do just this,
cmd.Parameters.AddWithValue("@Website" , If(tWebsite.Text , DBNull.Value))
from my understanding , that one line of code there DBNull.Value will replace tWebsite.Text as the value if tWebsite.Text is null or not accepted and it seems to me to do the same thing as the other function in General. Is this correct and is one way any better then the other?
Also , I get Warning : "Cannot Infer Common Type; Object Assumed" from the second way , but it seems to me that the first way was using a generic object anyways , so I do not know if I should just ignore this warning