从数据库读取值时出错
大家好...
我正在创建一个使用user_name和密码并经过身份验证后显示其个人资料页面的小型网站.
我使用SQL Server2005作为后端来检查user_name和密码并从数据库中读取用户ID.
现在,经过身份验证后,在配置文件页面中,当我尝试加载配置文件时,会显示一些错误消息.(尝试登录之前没有此类错误)
错误消息是:
nvarchar值"02357092887"的转换溢出了int列.超出了最大整数值.
其中"02357092887"是用户的uid.
我在配置文件页面中编写了以下代码以加载配置文件:
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
建议我该怎么办.
谢谢.
Gagan
suggest me what should I do.
Thanks.
Gagan
允许的最高INT值为2,147,483,647.您的ID已超过该ID.如果可能,您可以将NVARCHAR列投放到BIGINT中..
(如果所有ID值都超过Int值).
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)..