piter11
شنبه 27 دی 1393, 20:40 عصر
سلام من میخوام با دیتا گرید ویو یه ماشین حساب درست کنم که تیک خورد مبالغ جمع زده بشه حالا کدشو ایراد میگیره دو تا عکسم میزارم کسی میدونه مشکل چیه با سپاس
کد:
Dim ID As Integer = Integer.Parse(DataGridView1.CurrentRow.Cells(0).Va lue.ToString())
For Each row As DataGridViewRow In DataGridView1.Rows
If Convert.ToBoolean(row.Cells("check").Value) = True Then
con = New SqlConnection(My.Settings.Conn)
cmd = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "select sum(fi) from tblfi where id='" + ID.ToString + "'"
con.Open()
Dim sReader As SqlDataReader = cmd.ExecuteReader()
If sReader.Read() Then
'اینجا داده هایی مه توس Sreader خوندیم رو توی تکس باکس ها فراخوانی میکنیم
Label3.Text = sReader.GetValue(0).ToString()
Else : Label3.Text = 0
End If
con.Close()
cmd.Dispose()
End If
Next
127669
ارور کد:
127670
کد:
Dim ID As Integer = Integer.Parse(DataGridView1.CurrentRow.Cells(0).Va lue.ToString())
For Each row As DataGridViewRow In DataGridView1.Rows
If Convert.ToBoolean(row.Cells("check").Value) = True Then
con = New SqlConnection(My.Settings.Conn)
cmd = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "select sum(fi) from tblfi where id='" + ID.ToString + "'"
con.Open()
Dim sReader As SqlDataReader = cmd.ExecuteReader()
If sReader.Read() Then
'اینجا داده هایی مه توس Sreader خوندیم رو توی تکس باکس ها فراخوانی میکنیم
Label3.Text = sReader.GetValue(0).ToString()
Else : Label3.Text = 0
End If
con.Close()
cmd.Dispose()
End If
Next
127669
ارور کد:
127670