0

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'.

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)))
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by jireh
0
cmd.Parameters.AddWithValue(IIf(Val(Me.TxtCod) = 0, "Null", "@code", Val(Me.TxtCod)))

Note that IIF takes 3 parameters, adjust parenthesis of that.

cmd.Parameters.AddWithValue("@code", IIf(Val(Me.TxtCod) = 0, "Null", Val(Me.TxtCod)))

Please mark trhread closed if this helps.

0
cmd.Parameters.AddWithValue(IIf(Val(Me.TxtCod) = 0, "Null", "@code", Val(Me.TxtCod)))

Note that IIF takes 3 parameters, adjust parenthesis of that.

cmd.Parameters.AddWithValue("@code", IIf(Val(Me.TxtCod) = 0, "Null", Val(Me.TxtCod)))

Please mark trhread closed if this helps.

Dear Sir,
This line work fine

cmd.Parameters.AddWithValue("@desc", IIf(Len(Me.TxtDes) = 0, "Null", (Me.TxtDes)))

this line generates error as
value of type 'system.windows.form.textbox' can not be converted to "string".
trim is used in this line

cmd.Parameters.AddWithValue("@desc", IIf(Len(Me.TxtDes) = 0, "Null", trim(Me.TxtDes)))

Please help to send trimmed value to database while using above line

0

Please add dot text in your code...

cmd.Parameters.AddWithValue("@desc", IIf(Len(Me.TxtDes.Text) = 0, "Null", trim(Me.TxtDes.Text)))
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.