Specified argument was out of the range of valid values.
Parameter name:
this error display to me when i debug code ...
for this line
Line 115: GridView1.FooterRow.Cells(5).Text = count
What I have tried:
Sub load1()
Dim con As New SqlConnection
Dim cmd As New SqlCommand("Finance")
Dim Adapter As New SqlDataAdapter
cmd.CommandType = CommandType.StoredProcedure
Dim ds As New DataSet
Dim dt As New DataTable
'con.ConnectionString = "Server=.;Database=log;User Id=sa; Password=123;"
Dim constring = ConfigurationManager.ConnectionStrings("techConnectionString").ConnectionString()
con.ConnectionString = constring
cmd.Connection = con
Adapter.SelectCommand = cmd
'ds.Tables.Add(dt)
'cmd.Parameters.Add("@Id", SqlDbType.Int)
'cmd.Parameters("@Id").Value = txtID.Text
cmd.Parameters.Add("@m", SqlDbType.Int)
cmd.Parameters("@m").Value = 3
con.Open()
Adapter.Fill(ds, "tabel1")
con.Close()
Session("LoadData") = ds.Tables("tabel1")
GridView1.DataSource = ds.Tables("tabel1")
GridView1.DataBind()
'DirectCast(GridView1.FooterRow.Cells(3).FindControl("Label10"), Label).Text = dt.Compute("sum(Salary)", "").ToString()
'GridView1.FooterRow.Cells(0).Text = "Total = " & GridView1.Rows.Count.ToString()
'Dim sum As Integer=Convert.ToInt32(dt.Compute("SUM(Salary)", String.Empty))
'ds.Tables.Add(dt)
dt = ds.Tables(0)
Dim sum As Integer
For i = 0 To dt.Rows.Count - 1
'dt = ds.Tables("tabel1")
sum = sum + dt.Rows(i)("Salary")
Next
GridView1.FooterRow.Cells(3).Text = sum
Dim count As Integer = ds.Tables(0).Rows.Count
GridView1.FooterRow.Cells(5).Text = count
End Sub