Codes Modification

tqmd1

Well-known member
Joined
Dec 5, 2009
Messages
60
Programming Experience
Beginner
Dear Sir,
How to write these codes correctly.
It displays following tooltip
Too many arguments to 'public function iif(expression as bolean, truepart as object, falsepart as object) as object'.
VB.NET:
Dim cmd As New SqlClient.SqlCommand("Insert Into master (code) Values (@code)", con)
                cmd.Parameters.AddWithValue(IIf(Val(Me.TxtCod) = 0, "Null", "@code", Val(Me.TxtCod)))
 
Your IIF has four parameters here:
IIf( Val(Me.TxtCod) = 0 , "Null" , "@code" , Val(Me.TxtCod) )
And your AddWithValue call has only one:
AddWithValue( IIf(...) )
The AddWithValue function needs two parameters; (parameterName , value)
And IIf function has as error told you three parameters; (expression , truepart , falsepart)

Can you now see what needs to be rearranged?
 
Back
Top