我有一个像这样的网页
名称:[TextBox]
输入密码:[TextBox] [Label] [Label]
输入密码:[TextBox] [Label] [Label]
同样还有3个TextBox用于从用户那里获取密码.....我实际上是在计算用户在每个文本框中输入相同密码所需的时间......
所以我这样做了....
function focusFunction2() {
document.getElementById("TextBox2").style.background = "yellow";
var d = new Date();
document.getElementById("Label2").innerText = (d.getTime() % 10000000);
}
并使用blurFunction计算用户留在此文本框之前的时间
function blurFunction2() {
document.getElementById("TextBox2").style.background = "red";
var d = new Date();
document.getElementById("Label7").innerText = (d.getTime() % 10000000);
}
类似于其他文本框
并在按钮上单击尝试将其存储在我的数据库中
protected void Button1_Click(object sender, EventArgs e) {
string cs = ConfigurationManager.ConnectionStrings["DBMS"].ConnectionString;
using(SqlConnection con = new SqlConnection(cs)) {
SqlCommand cmd = new SqlCommand("spRegisterUser", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", TextBox1.Text);
cmd.Parameters.AddWithValue("@Password", TextBox2.Text);
cmd.Parameters.AddWithValue("@time1", int.Parse(Label7.Text));
cmd.Parameters.AddWithValue("@time2", int.Parse(Label8.Text));
cmd.Parameters.AddWithValue("@time3", int.Parse(Label9.Text));
cmd.Parameters.AddWithValue("@time4", int.Parse(Label10.Text));
cmd.Parameters.AddWithValue("@time5", int.Parse(Label11.Text));
con.Open();
int ReturnCode = (int) cmd.ExecuteScalar();
if (ReturnCode == -1) {
Label12.ForeColor = System.Drawing.Color.Red;
Label12.Text = "User Name already in Use , Please use another user name";
}
}
}
然后它成功运行,甚至在每个标签上显示不同的进入和退出时间,但在按钮上单击它显示此错误"输入字符串的格式不正确"在这个位置。
cmd.Parameters.AddWithValue("@time1", int.Parse(Label7.Text));
我使用过这个存储过程
create proc spRegisterUser
@UserName nvarchar(100),
@Password nvarchar(100),
@time1 int,
@time2 int,
@time3 int,
@time4 int,
@time5 int
as
Begin
Declare @count int
Set @Count = (@time1 + @time2 + @time3 + @time4 + @time5)/5
Begin
--Change: Column list specified while inserting
Insert into register
values (@UserName, @Password, @time1,@time2,@time3,@time4,@time5,@count)
End
End