toopak
سه شنبه 26 شهریور 1387, 16:28 عصر
سلام دوستان
من یه کد دارم که اینه
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Label1.Text = ComboBox1.Text.ToString
Dim ds As New DataSet
Dim inssql As String
Dim cmdsql As New OleDbCommand
inssql = "SELECT count(sid) as noo,sum(fee*(comi/100)) as ajans,sum(fee) as allfee,sum(fee-(fee*(comi/100))) as driver FROM tbservices where drname='" & Label1.Text & "'"
cmdsql.Connection = con
cmdsql.CommandText = inssql
Dim DR As OleDbDataReader
DR = cmdsql.ExecuteReader
DR.Read()
If DR.HasRows = False Then
Label4.Text = ""
Label3.Text = ""
Label2.Text = ""
Label5.Text = ""
Else
Label4.Text = DR("allfee")
Label3.Text = DR("driver")
Label2.Text = DR("ajans")
Label5.Text = DR("noo")
End If
End Sub
کارش اینه که از توی دیتابیس یه سری اطلاعات رو استخراج میکنه
بر اساس یکی از فیلدها
حالا مشکل اینه که وقتی پیدا نمیکنه به جای اینکه
این دستور رو اجرا کنه
Label4.Text = ""
Label3.Text = ""
Label2.Text = ""
Label5.Text = ""
تو قسمت قرمز ارور زیر رو میده
Conversion from type 'DBNull' to type 'String' is not valid
این یعنی چی؟
من یه کد دارم که اینه
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Label1.Text = ComboBox1.Text.ToString
Dim ds As New DataSet
Dim inssql As String
Dim cmdsql As New OleDbCommand
inssql = "SELECT count(sid) as noo,sum(fee*(comi/100)) as ajans,sum(fee) as allfee,sum(fee-(fee*(comi/100))) as driver FROM tbservices where drname='" & Label1.Text & "'"
cmdsql.Connection = con
cmdsql.CommandText = inssql
Dim DR As OleDbDataReader
DR = cmdsql.ExecuteReader
DR.Read()
If DR.HasRows = False Then
Label4.Text = ""
Label3.Text = ""
Label2.Text = ""
Label5.Text = ""
Else
Label4.Text = DR("allfee")
Label3.Text = DR("driver")
Label2.Text = DR("ajans")
Label5.Text = DR("noo")
End If
End Sub
کارش اینه که از توی دیتابیس یه سری اطلاعات رو استخراج میکنه
بر اساس یکی از فیلدها
حالا مشکل اینه که وقتی پیدا نمیکنه به جای اینکه
این دستور رو اجرا کنه
Label4.Text = ""
Label3.Text = ""
Label2.Text = ""
Label5.Text = ""
تو قسمت قرمز ارور زیر رو میده
Conversion from type 'DBNull' to type 'String' is not valid
این یعنی چی؟