inserting 10 digits number from textbox to sql server 2005 error
It try to insert 10 digits number to database sql server through textbox it give me this error.
Here is the code which i use for validation the textbox
Code:
Private Sub contacttxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles contacttxt.KeyPress
If (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) And e.KeyChar <> Chr(8) Then
MessageBox.Show("cannot enter char selection only ")
e.Handled = True
Else
If contacttxt.Text.Length >= 10 Then
If e.KeyChar <> ControlChars.Back Then
MsgBox("Only 10 Digit")
e.Handled = True
End If
End If
End If
End Sub
Re: inserting 10 digits number from textbox to sql server 2005 error
That's telling the textbox to only accept the number keys and the backspace. First, I would take a look at JMc's blog on parameters. But I guess ultimately how are you displaying the data? Did you drag it from your datasources? As of right now it's kinda hard to help you out with just seeing that you want your textbox to only accept numbers.
Re: inserting 10 digits number from textbox to sql server 2005 error
As with displaying the data i use datagridview. when i enter only 9 digits it work fine but when i enter upto 10 digits it give me this error.
Quote:
The conversion of the varchar value '3242342342' overflowed an int column. Maximum integer value exceeded.
The statement has been terminated.
Re: inserting 10 digits number from textbox to sql server 2005 error
Change the datatype from INT to BIGINT. I'm asssuming it is int.
Does not work:
create table #VBForums (TestIt int)
insert into #VbForums(TestIt) Values(3242342342)
drop table #VBForums
Works:
create table #VBForums (TestIt bigint)
insert into #VbForums(TestIt) Values(3242342342)
drop table #VBForums
Re: inserting 10 digits number from textbox to sql server 2005 error
If you are using Int as a data type 10 digits will work if the first number is a 1 and may work if it is a 2, will always fail if the first digit is greater than 2
This is the max value range for an Int data type
-2,147,483,648 to 2,147,483,647
Re: inserting 10 digits number from textbox to sql server 2005 error
Quote:
Originally Posted by
DataMiser
If you are using Int as a data type 10 digits will work if the first number is a 1 and may work if it is a 2, will always fail if the first digit is greater than 2
This is the max value range for an Int data type
-2,147,483,648 to 2,147,483,647
I can't be sure with out seeing the app but I suspect the overflow is on the SQL server datatype. If you run the one I marked as doesn't work you will get the overflow message mentioned.
oops...maybe that is what you meant.
Re: inserting 10 digits number from textbox to sql server 2005 error
Re: inserting 10 digits number from textbox to sql server 2005 error
simplier answer. use datatype double :) with len 10,0