| |

VerySource

 Forgot password?
 Register
Search
View: 1091|Reply: 3

The cast from type "DBNull" to type "Integer" is invalid

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-24 18:00:02
| Show all posts |Read mode
A function is defined Public Function RunCard_Query(ByVal strtype As String, ByVal strdate As String, ByVal strclass As String) As DataSet
Dim data As New DataSet()
dsCommand.SelectCommand = New SqlCommand("SELECT MAX(CAST(SUBSTRING(RUNCARD,2,9) AS INTEGER)) AS NUM FROM RUNCARD WHERE TYPE ='" + strtype + "'AND CLASSNAME ='" + strclass + "'AND RUNCARD LIKE'" + strdate + "'+'%'", con)
'dsCommand.SelectCommand = New SqlCommand("SELECT COUNT(*) AS NUM FROM RUNCARD WHERE TYPE ='" + strtype + "'AND CLASSNAME ='" + strclass + "'AND RUNCARD LIKE'" + strdate + "'+ ' %'", con)
dsCommand.Fill(data)
RunCard_Query = data
End Function
Reference ds = mySqlData.RunCard_Query("Wafer_Lot", strdate, "PRO")
Dim i As Integer
Dim j As Integer

i = ds.Tables(0).Rows(0)("num")

j = i + 1
...
As a result, it says that the coercive conversion from type "DBNull" to type "Integer" is invalid. Please expert advice, urgent!!!
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-24 18:15:01
| Show all posts
SELECT ISNULL(MAX(CAST(SUBSTRING(RUNCARD,2,9) AS INTEGER)),0) AS NUM FROM RUNCARD WHERE TYPE ...
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-24 18:30:01
| Show all posts
ISNULL(...,0) as NUM
Reply

Use magic Report

0

Threads

48

Posts

30.00

Credits

Newbie

Rank: 1

Credits
30.00

 China

Post time: 2020-12-24 19:30:02
| Show all posts
j=iif(isdbnull(ds.Tables(0).Rows(0)("num")),0,ds.Tables(0).Rows(0)("num"))
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list