It's working fine but the error is 'Input string was not in a correct format.'

CCrayv2/17/2023
Can anyone help me here i'll post the error
Image
CCrayv2/17/2023
Image
CCrayv2/17/2023
and here is the database Table
CCrayv2/17/2023
Image
CCrayv2/17/2023
thank you for helping
CCrayv2/17/2023
I also tried the Convert.ToInt32 one it's the smae
TTheRanger2/17/2023
hover ur mouse on txtSupplierID.Text while the error message is displayed to see its value
TTheRanger2/17/2023
@Crayv
CCrayv2/17/2023
wdynm hover?
TTheRanger2/17/2023
like put ur mouse over it
CCrayv2/17/2023
Image
CCrayv2/17/2023
oh
SMTRSUPER MEGA T REX2/17/2023
That's too large for a 16 bit integer.
CCrayv2/17/2023
Nononon that's not updated
CCrayv2/17/2023
its Convert.ToInt32 one
CCrayv2/17/2023
hehe
SMTRSUPER MEGA T REX2/17/2023
You may need to call Trim on the string if it contains a space.
SMTRSUPER MEGA T REX2/17/2023
Also, you should look into int.TryParse.
TTheRanger2/17/2023
lets just see its value first
TTheRanger2/17/2023
hover ur mouse on txtSupplierID.Text while the error message is displayed to see its value
CCrayv2/17/2023
Image
CCrayv2/17/2023
i can't over because the error will appear
CCrayv2/17/2023
hover
TTheRanger2/17/2023
you can
TTheRanger2/17/2023
just put ur mouse there
CCrayv2/17/2023
like this?
CCrayv2/17/2023
Image
CCrayv2/17/2023
or do i not run it
TTheRanger2/17/2023
on txtSupplierID.Text in ur visual studio
TTheRanger2/17/2023
something like this should appear
Image
CCrayv2/17/2023
empty
CCrayv2/17/2023
Image
CCrayv2/17/2023
it's a textbox
TTheRanger2/17/2023
Image
TTheRanger2/17/2023
hover ur mouse on that circle
TTheRanger2/17/2023
a small window like this will pop up
CCrayv2/17/2023
Image
TTheRanger2/17/2023
while the System.FormatException is popped up
TTheRanger2/17/2023
u can only see its value when the program is crashed
CCrayv2/17/2023
okay what does that mean?
TTheRanger2/17/2023
when you see this error
TTheRanger2/17/2023
hover ur mouse on the circle
CCrayv2/17/2023
okok wait
CCrayv2/17/2023
Image
TTheRanger2/17/2023
Image
TTheRanger2/17/2023
its empty
TTheRanger2/17/2023
u cant convert an empty string to an integer
CCrayv2/17/2023
it's not empty tho...
CCrayv2/17/2023
Image
CCrayv2/17/2023
i put in the value and then add it in the database
CCrayv2/17/2023
so it's not empty
TTheRanger2/17/2023
hmm, maybe wrong textbox?
CCrayv2/17/2023
i don't think so
CCrayv2/17/2023
it's working for everything except the supplier
TTheRanger2/17/2023
well go to ur designer mode
TTheRanger2/17/2023
click on the supplier id textbox
TTheRanger2/17/2023
see what's it called
CCrayv2/17/2023
what's called?
TTheRanger2/17/2023
the textbox
CCrayv2/17/2023
it's called txtSupplierID
TTheRanger2/17/2023
i have to see the proof
TTheRanger2/17/2023
screenshot or anything
CCrayv2/17/2023
Image
CCrayv2/17/2023
is this correct?
TTheRanger2/17/2023
thats not the issue, no need to post it
CCrayv2/17/2023
okayokay i just thought maybe
CCrayv2/17/2023
it's my first time creating a 3 layer application
PPobiega2/17/2023
well your error is from Convert.ToInt32, which is a parsing method
PPobiega2/17/2023
and its throwing a parsing error, because the string is empty. so we need to figure out why it is
CCrayv2/17/2023
hmmm
TTheRanger2/17/2023
what about the rest of the textboxes? try hovering on them
CCrayv2/17/2023
but it's not empty :((
PPobiega2/17/2023
the debugger doesnt agree with you
PPobiega2/17/2023
and I trust the debugger 🙂
CCrayv2/17/2023
well that's true
PPobiega2/17/2023
yeah do what Ranger suggested, make sure they have values as expected
CCrayv2/17/2023
wait check this out
CCrayv2/17/2023
Image
CCrayv2/17/2023
i'm gonna add this to the database
CCrayv2/17/2023
Image
CCrayv2/17/2023
it's successfully got added but got the error afterwards
CCrayv2/17/2023
lemme check
PPobiega2/17/2023
but your error is in
Image
PPobiega2/17/2023
thats the Add method, and the very first line
TTheRanger2/17/2023
so when u click add, it adds to the database, then the error pops up?
CCrayv2/17/2023
yup
PPobiega2/17/2023
Are you doubleclicking it or something?
PPobiega2/17/2023
so it adds, wipes the field, runs again..
CCrayv2/17/2023
it doesn't run again it close
PPobiega2/17/2023
that sounds exactly like whats happening
TTheRanger2/17/2023
can u show the ClearText method?
CCrayv2/17/2023
wait i don't know how to explain
CCrayv2/17/2023
because i have 2 class
CCrayv2/17/2023
Image
CCrayv2/17/2023
i just do this for cleaner looks
TTheRanger2/17/2023
well it definitely sounds like ur double clicking it
PPobiega2/17/2023
the fix is easy thou
PPobiega2/17/2023
use int.TryParse instead of Convert.ToInt32
PPobiega2/17/2023
any place where you are getting a string from the user, use tryparse