searchsanjaysharma
asked on
How to correct this error and why it comes.
I have a windows form and coding in vb.net.
A textbox txttid is there.
When i enter any numbers if fetches the data based on that tid and returns the resultset.
If no data is available then it gives invalid TID as message
empties the txttid.But simultenously raises the following exception
The Query is :
s = "select isnull(sname,''),isnull(ge nder,''),i snull(slan dline,''), isnull(smo bile,''),i snull(ssta te,'') from mststudents where id=" & Convert.ToInt32(TXTTID.Tex t.Trim()) & " and sname is null"
da = New SqlDataAdapter(s, con)
dt = New DataTable
da.Fill(dt)
If dt.Rows.Count = 0 Then
MessageBox.Show("Invalid TID")
TXTTID.Text = ""
TXTTID.Focus()
txtuin.Text = ""
txtuin.Enabled = False
Else
txtsname.Text = dt.Rows(0)(0).ToString()
end if
Exception is System.Format Exception. Input string was not in correct format.
A textbox txttid is there.
When i enter any numbers if fetches the data based on that tid and returns the resultset.
If no data is available then it gives invalid TID as message
empties the txttid.But simultenously raises the following exception
The Query is :
s = "select isnull(sname,''),isnull(ge
da = New SqlDataAdapter(s, con)
dt = New DataTable
da.Fill(dt)
If dt.Rows.Count = 0 Then
MessageBox.Show("Invalid TID")
TXTTID.Text = ""
TXTTID.Focus()
txtuin.Text = ""
txtuin.Enabled = False
Else
txtsname.Text = dt.Rows(0)(0).ToString()
end if
Exception is System.Format Exception. Input string was not in correct format.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok
See #2 here: https://www.experts-exchange.com/Programming/Languages/.NET/A_5389-5-Common-Exceptions-in-NET-and-How-to-Resolve-Them.html