نسرین2000
دوشنبه 11 فروردین 1393, 09:44 صبح
سلام
قطعه کد زیر رو برای بدست آوردن اختلاف دو تاریخ نوشتم ولی زمانی که فرم لود می شود ارور زیر را می دهد ؟
Invalid attempt to read when no data is present
Private Sub txtdate_kh_TextChanged(sender As Object, e As EventArgs) Handles txtdate_kh.TextChanged
Dim objcommand As New SqlCommand
objcommand.Connection = objconnection
objcommand.CommandText = " select date_vorood1 from suite where guest_id=@guest_id"
objcommand.Parameters.AddWithValue("@guest_id", txtguest_id.Text)
Dim sreader As SqlDataReader
objconnection.Open()
sreader = objcommand.ExecuteReader()
Dim a As Date
Dim i As Integer
a = System.DateTime.Today
i = DateDiff("n", a, CDate(sreader.Item("date_vorood1")))
txtmodat_eghamat.Text = i
objconnection.Close()
End Sub
قطعه کد زیر رو برای بدست آوردن اختلاف دو تاریخ نوشتم ولی زمانی که فرم لود می شود ارور زیر را می دهد ؟
Invalid attempt to read when no data is present
Private Sub txtdate_kh_TextChanged(sender As Object, e As EventArgs) Handles txtdate_kh.TextChanged
Dim objcommand As New SqlCommand
objcommand.Connection = objconnection
objcommand.CommandText = " select date_vorood1 from suite where guest_id=@guest_id"
objcommand.Parameters.AddWithValue("@guest_id", txtguest_id.Text)
Dim sreader As SqlDataReader
objconnection.Open()
sreader = objcommand.ExecuteReader()
Dim a As Date
Dim i As Integer
a = System.DateTime.Today
i = DateDiff("n", a, CDate(sreader.Item("date_vorood1")))
txtmodat_eghamat.Text = i
objconnection.Close()
End Sub