Protected Sub grvPos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles grvPos.RowCommand
If e.CommandName = "Insert" AndAlso Page.IsValid Then
Dim Index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = grvPos.Rows(Index)
Dim cs As String
Dim con As iDB2Connection
Dim sql As String
Dim cmd As iDB2Command
Dim valDate = grvPos.DataKeys(Index).Values(1)
Dim portCode As String = grvPos.DataKeys(Index).Values(3).ToString()
Dim secCode As String = grvPos.DataKeys(Index).Values(10).ToString()
Dim valType As TextBox = CType(row.FindControl("txtValType"), TextBox)
Dim portSName As TextBox = CType(row.FindControl("txtPortSName"), TextBox)
Dim portName As TextBox = CType(row.FindControl("txtPortName"), TextBox)
Dim secName As TextBox = CType(row.FindControl("txtSecName"), TextBox)
Dim secCcyAbbr As TextBox = CType(row.FindControl("txtSecCcyAbbr"), TextBox)
Dim portGrpCD As TextBox = CType(row.FindControl("txtPortGrpCD"), TextBox)
Dim portGrpNAme As TextBox = CType(row.FindControl("txtPortGrpName"), TextBox)
Dim prd As TextBox = CType(row.FindControl(""), TextBox)
Dim cent As TextBox = CType(row.FindControl("txtCentre"), TextBox)
Dim centName As TextBox = CType(row.FindControl("txtCentreName"), TextBox)
Dim secCcy As TextBox = CType(row.FindControl("txtSecCcy"), TextBox)
Dim secExRate As TextBox = CType(row.FindControl("txtScBcExRate"), TextBox)
Dim baseCcy As TextBox = CType(row.FindControl("txtBaseCcy"), TextBox)
Dim mValSc As TextBox = CType(row.FindControl("txtMvalAmtSc"), TextBox)
Dim mValBc As TextBox = CType(row.FindControl("txtMvalAmtBc"), TextBox)
cs = ConfigurationManager.ConnectionStrings("ConnectionStringDB2").ConnectionString
con = New iDB2Connection(cs)
sql = "INSERT INTO PFDTA.OPTR_POS3 (" &
"VALN_DATE,VAL_TYPE,PORT_CODE,PORT_SNAME" &
",PORT_NAME,PORT_GROUP_CD,PORT_GROUP_NAME" &
",CENTRE,CENTRE_NAME,SEC_CODE,SEC_SNAME" &
",SEC_CCY,SEC_CCY_ABBR,SC_BC_EX_RATE" &
",BASE_CCY,MVAL_AMT_SC,MVAL_AMT_BC" &
",PRD) VALUES (@VALN_DATE,@VAL_TYPE" &
",@PORT_CODE,@PORT_SNAME,@PORT_NAME" &
",@PORT_GROUP_CD,@PORT_GROUP_NAME" &
",@CENTRE,@CENTRE_NAME,@SEC_CODE" &
",@SEC_SNAME,@SEC_CCY,@SEC_CCY_ABBR" &
",@SC_BC_EX_RATE,@BASE_CCY" &
",@MVAL_AMT_SC,@MVAL_AMT_BC" &
",@PRD)"
cmd = New iDB2Command(sql, con)
cmd.Parameters.AddWithValue("@VALN_DATE", valDate)
cmd.Parameters.AddWithValue("@PORT_CODE", portCode)
cmd.Parameters.AddWithValue("@SEC_CODE", secCode)
cmd.Parameters.AddWithValue("@VAL_TYPE", valType)
cmd.Parameters.AddWithValue("@PORT_SNAME", portSName)
cmd.Parameters.AddWithValue("@PORT_NAME", portName)
cmd.Parameters.AddWithValue("@PORT_GROUP_CD", portGrpCD)
cmd.Parameters.AddWithValue("@PORT_GROUP_NAME", portGrpNAme)
cmd.Parameters.AddWithValue("@CENTRE", cent)
cmd.Parameters.AddWithValue("@CENTRE_NAME", centName)
cmd.Parameters.AddWithValue("@SEC_CCY", secCcy)
cmd.Parameters.AddWithValue("@SC_BC_EX_RATE", secExRate)
cmd.Parameters.AddWithValue("@BASE_CCY", baseCcy)
cmd.Parameters.AddWithValue("@MVAL_AMT_SC", mValSc)
cmd.Parameters.AddWithValue("@MVAL_AMT_BC", mValBc)
cmd.Parameters.AddWithValue("@SEC_SNAME", secName)
cmd.Parameters.AddWithValue("@SEC_CCY_ABBR", secCcyAbbr)
cmd.Parameters.AddWithValue("@PRD", prd)
Try
lblError.Text = ""
Using con
con.Open()
cmd.ExecuteNonQuery()
gridLoad()
End Using
Catch ex As Exception
Throw
End Try
End If
End Sub
I appreciate any help on how to get the insert command insert the values specified in the code.
The is no CommandArgument set on your Gridview, unless you set, it will be string.empty ("").
So Convert.toInt32("") = Input string was not in correct format
By the way, you should set CommandArgument property on all LinkButtons with a value that best fit your needs
Member
28 Points
147 Posts
Need help figuring out the error: Input string was not in a correct format.
Apr 10, 2019 11:20 AM|Matt99|LINK
The error occurs after clicking on the insert command in the footer row.
Error point to:
Dim Index As Integer = Convert.ToInt32(e.CommandArgument)
The html page:
code page:
I appreciate any help on how to get the insert command insert the values specified in the code.
Thanks in advance
Participant
1061 Points
666 Posts
Re: Need help figuring out the error: Input string was not in a correct format.
Apr 10, 2019 01:56 PM|jzero|LINK
The is no CommandArgument set on your Gridview, unless you set, it will be string.empty ("").
So Convert.toInt32("") = Input string was not in correct format
By the way, you should set CommandArgument property on all LinkButtons with a value that best fit your needs
Member
28 Points
147 Posts
Re: Need help figuring out the error: Input string was not in a correct format.
Apr 10, 2019 06:03 PM|Matt99|LINK
Solved the problem differently: