从数据库读取值时出错

从数据库读取值时出错

本文介绍了从数据库读取值时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...

我正在创建一个使用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

推荐答案


这篇关于从数据库读取值时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:47