高手赶快来帮忙解决,想不通为什么会这样,
我现在用vs.net2005 编写的如下程序,和出错的提示
为什么,高手解决
string username, password;
int datarows;
username = txtUser.Text;
password = txtPass.Text;
PublicCls pc = new PublicCls();
SqlConnection conn=new SqlConnection(pc.strConn);
string SQL = "select * from T_User where F_UserName=@username";
SqlCommand Cmd = new SqlCommand(SQL, conn);
SqlParameter parInput = Cmd.Parameters.Add("@username", SqlDbType.Int);
parInput.Direction = ParameterDirection.Input;
parInput.Value = username;
SqlDataAdapter da = new SqlDataAdapter();
conn.Open();
da.SelectCommand = Cmd;
DataSet ds = new DataSet();
datarows = da.Fill(ds,"test");
conn.Close();
错误提示:
输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.FormatException: 输入字符串的格式不正确。
源错误:
行 33: da.SelectCommand = Cmd;
行 34: DataSet ds = new DataSet();
行 35: datarows = da.Fill(ds,"test");
行 36: conn.Close();
行 37: if (datarows == 0)
源文件: c:\Documents and Settings\cqfmp\My Documents\Visual Studio 2005\WebSites\PS\Login.aspx.cs 行: 35
堆栈跟踪:
[FormatException: 输入字符串的格式不正确。]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2752819
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +214
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) +738
[FormatException: 将参数值从 String 转换到 Int32 失败。]