Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all...

I am creating a small website which takes user_name and password and after authentication showing its profile page.

I used SQL Server2005 as backend to check user_name and password and reading user id from database.

Now after authentication, in profile page, when I'm trying to load the profile it give some error message.(There were no such error before I tried to login)

The error message is :
The conversion of the nvarchar value '02357092887' overflowed an int column. Maximum integer value exceeded.

where '02357092887' is the uid of user.

I wrote following code in profile page to load profile :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
dim uid=Convert.ToString(Request.QueryString("uid"))

        conClass.Connect() 'Opening database connection.

        Dim sql As String = "select fname,gender,dob from login where uid=" & uid 
        Dim cmd As New SqlCommand(sql, conClass.con) 
        Dim reader As SqlDataReader = cmd.ExecuteReader 
        While reader.Read   'This line shows error.
            lblFname.Text = reader.GetString(0)
            Page.Title = reader.GetString(0) 
            lblGender.Text = reader.GetString(1) 
            lblDOB.Text = reader.GetString(2)
        End While
        reader.Close()

End Sub


suggest me what should I do.

Thanks.

Gagan
Posted
Comments
nagendrathecoder 17-Sep-10 2:23am    
Try to debug your code and see what you are getting in "uid".
Try to run query on Sql Server.
Gagan.20 17-Sep-10 2:51am    
Debugging code is giving same uid as 02357092887

1 solution

The highest allowable INT value is 2,147,483,647. Your id has exceeded that.If possible you CAST your NVARCHAR column into a BIGINT instead..
(If all the ID values are above Int value)..
 
Share this answer
 
v2
Comments
Gagan.20 17-Sep-10 2:51am    
Thanks sir for your reply. But after casting NVARCHAR column into a BIGINT, it shows error- Arithmetic overflow error converting nvarchar to data type numeric.

I have a NUM column (first column of database) in my database which is of BIGINIT type. I think it is showing error when reader starts reading values from database, it is getting the numeric value for NUM column with NVARCHAR column of uid because if I am writing SQL query for selected fields as - select uid,name
Dalek Dave 17-Sep-10 3:29am    
Good answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900