dr223
March 31st, 2009, 06:09 AM
Hallo,
I have the following piece of Code in my application shown below,
Try
Dim Oracle_num As New System.Data.SqlClient.SqlCommand(("SELECT Oracle_no FROM gprdsql.TblOracleNos WHERE Prac_no='" & _
Me.TxtPracNo.Text & "' and Prac_eid = '" & _
Me.TxtPracEid.Text & "' and Pay_method = '" & _
Me.CmbPayMethod.Text & "' "), conn)
Using reader As System.Data.SqlClient.SqlDataReader = Oracle_num.ExecuteReader()
While reader.Read()
Dim Oracle_no As String = FixNull(reader.GetValue(0))
TxtOracleNo.Text = Oracle_no
End While
End Using
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "GCPM")
End Try
When I run the application and try to save when the TxtOracleNo textbox is null (no value) then the following error is prompted,
"Error converting data type varchar to numeric" when you ok it the data is saved, regardless. In the database oracle_no is set as numeric data type.
The error is the red highlighted code. So I tried the following;
Dim Oracle_no As Integer = FixNullInteger(reader.GetValue(0))
This doesnt work and the application fails to run, highlighting the error on the above code. Also note, the error is only prompted if you are saving when the TxtOracleNo has no value and save button clicked but if it is populated by a value it saves ok without any error prompted.
Any ideas!!!
Thank you
I have the following piece of Code in my application shown below,
Try
Dim Oracle_num As New System.Data.SqlClient.SqlCommand(("SELECT Oracle_no FROM gprdsql.TblOracleNos WHERE Prac_no='" & _
Me.TxtPracNo.Text & "' and Prac_eid = '" & _
Me.TxtPracEid.Text & "' and Pay_method = '" & _
Me.CmbPayMethod.Text & "' "), conn)
Using reader As System.Data.SqlClient.SqlDataReader = Oracle_num.ExecuteReader()
While reader.Read()
Dim Oracle_no As String = FixNull(reader.GetValue(0))
TxtOracleNo.Text = Oracle_no
End While
End Using
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "GCPM")
End Try
When I run the application and try to save when the TxtOracleNo textbox is null (no value) then the following error is prompted,
"Error converting data type varchar to numeric" when you ok it the data is saved, regardless. In the database oracle_no is set as numeric data type.
The error is the red highlighted code. So I tried the following;
Dim Oracle_no As Integer = FixNullInteger(reader.GetValue(0))
This doesnt work and the application fails to run, highlighting the error on the above code. Also note, the error is only prompted if you are saving when the TxtOracleNo has no value and save button clicked but if it is populated by a value it saves ok without any error prompted.
Any ideas!!!
Thank you