Hi,

This is mahendiran,please anybody help me....

i m getting error like cast from type ‘DBNull’ to type ‘String’ is not valid.

Dim newcollection As String

newcollection = "select sum(AMT_PAID) from PAYMENT_HISTORY where BILL_NO LIKE '*" & Session("BRANCH") & "*' and BILL_MODE='NEW' and "

If Drp_From_Day.SelectedIndex <> 0 And Drp_From_Month.SelectedIndex <> 0 And Drp_From_Year.SelectedIndex <> 0 Then
If Drp_To_Day.SelectedIndex <> 0 And Drp_To_Month.SelectedIndex <> 0 And Drp_To_Year.SelectedIndex <> 0 Then
Dim Fdate, Tdate As Date
Fdate = DateSerial(Val(Drp_From_Year.SelectedItem.Text), Drp_From_Month.SelectedItem.Value, Val(Drp_From_Day.SelectedItem.Text))
Tdate = DateSerial(Val(Drp_To_Year.SelectedItem.Text), Drp_To_Month.SelectedItem.Value, Val(Drp_To_Day.SelectedItem.Text))
newcollection = newcollection & "PAID_DATE>=#" & Fdate & "# AND PAID_DATE<=#" & Tdate & "# "
End If
End If
cmd = New OleDbCommand(newcollection, Conn)
lbl_newcoll.Text = cmd.ExecuteScalar()


help me...................please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks
Mahendiran

Hey Mahendiran, try this in your code; lbl_newcoll.Text = cmd.ExecuteScalar().toString & ""

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.