A
antonio-jr
Guest
Hi Expert,
Please correct were I got wrong, this is my code and the error is showing
ERROR:
System.InvalidCastException
HResult=0x80004002
Message=Conversion from string "" to type 'Integer' is not valid.
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at FormworksINterface.UPDATESMR.TextBox5_Validated(Object sender, EventArgs e) in D:\VB\myAppsProgram\FMS77\FormworksINterface\UPDATESMR.vb:line 362
at System.Windows.Forms.Control.OnValidated(EventArgs e)
at System.Windows.Forms.Control.PerformControlValidation(Boolean bulkValidation)
at System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control ancestorControl, Boolean preventFocusChangeOnError)
Inner Exception 1:
FormatException: Input string was not in a correct format.
----------------------------------------------------------------------------
My Code:
Try
connection = New SqlConnection("Data Source=192.168.210.97;Initial Catalog=FormworksTest;User ID=sa;Password=Cr@shfr33!")
Dim READER As SqlDataReader
Dim bSource As New BindingSource
Dim SDA As New SqlDataAdapter
Dim answer As Integer = Plus(CType(Label22.Text, Integer), CType(TextBox5.Text, Integer))
Dim number1, number2, result As Integer
number2 = TextBox5.Text
number1 = Label22.Text
result = number1 + number2
Label20.Text = result
If result > 0 Then
MsgBox("Your current Stocks is, '" & Label20.Text & "'", MsgBoxStyle.Information, "Current Stocks")
'AlertMessages.Show()
'Exit Sub
Else
connection.Open()
Dim query As String
query = "UPDATE SAPCONSUMABLE SET AvailableStock='" & Label20.Text & "' where ItemNo='" & ComboBox2.Text & "'"
command = New SqlCommand(query, connection)
READER = command.ExecuteReader
'MessageBox.Show("Stock is updated", "Stocks is updated")
End If
connection.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
connection.Dispose()
connection.Close()
End Try
End Sub
thank you the any help
Continue reading...
Please correct were I got wrong, this is my code and the error is showing
ERROR:
System.InvalidCastException
HResult=0x80004002
Message=Conversion from string "" to type 'Integer' is not valid.
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at FormworksINterface.UPDATESMR.TextBox5_Validated(Object sender, EventArgs e) in D:\VB\myAppsProgram\FMS77\FormworksINterface\UPDATESMR.vb:line 362
at System.Windows.Forms.Control.OnValidated(EventArgs e)
at System.Windows.Forms.Control.PerformControlValidation(Boolean bulkValidation)
at System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control ancestorControl, Boolean preventFocusChangeOnError)
Inner Exception 1:
FormatException: Input string was not in a correct format.
----------------------------------------------------------------------------
My Code:
Try
connection = New SqlConnection("Data Source=192.168.210.97;Initial Catalog=FormworksTest;User ID=sa;Password=Cr@shfr33!")
Dim READER As SqlDataReader
Dim bSource As New BindingSource
Dim SDA As New SqlDataAdapter
Dim answer As Integer = Plus(CType(Label22.Text, Integer), CType(TextBox5.Text, Integer))
Dim number1, number2, result As Integer
number2 = TextBox5.Text
number1 = Label22.Text
result = number1 + number2
Label20.Text = result
If result > 0 Then
MsgBox("Your current Stocks is, '" & Label20.Text & "'", MsgBoxStyle.Information, "Current Stocks")
'AlertMessages.Show()
'Exit Sub
Else
connection.Open()
Dim query As String
query = "UPDATE SAPCONSUMABLE SET AvailableStock='" & Label20.Text & "' where ItemNo='" & ComboBox2.Text & "'"
command = New SqlCommand(query, connection)
READER = command.ExecuteReader
'MessageBox.Show("Stock is updated", "Stocks is updated")
End If
connection.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
connection.Dispose()
connection.Close()
End Try
End Sub
thank you the any help
Continue reading...