Metode ExecuteScalar()
returnerer System.Object
så skift din kode.
Dim value=cmd2.ExecuteScalar()
IF Not IsNoThing(value) Then
result=Decimal.Parse(value.ToString())
End IF
Eller du kan bruge ExecuteReader,
Dim dr2 As OracleDataReader = cmd2.ExecuteReader()
Dim value as Decimal
If dr2.Read() Then
IF Not dr2.IsDbNull(0)
Value=dr2.GetDecimal(0)
End IF
End If
Og altid brug parametre i stedet for hårdkodet sql-streng.
cmd2.CommandText = "SELECT MAX(LASTNO) FROM d001005 where [email protected] and CODE1='CASH' and [email protected]"
cmd2.Parameters.Add("@lbrcode",SqlDbType.VarChar,20).Value=lbr
.....