从c#asp.net将数字记录插入ms access

从c#asp.net将数字记录插入ms access,c#,asp.net,ms-access,insert,numeric,C#,Asp.net,Ms Access,Insert,Numeric,这给了我一个错误,输入字符串的格式不正确。请帮助我。根据代码和错误,TextBox控件的文本(txtContact或txtAge)很可能不是有效的整数(整数)值。确保您正在验证输入。您应该使用RequiredFieldValidator以及RangeValidator或RegularExpressionValidator来确保文本框不是空的并且包含有效文本 你也可以考虑使用转换。totIt32. 你将非整数值转换成整数值,请检查 txTACT.Text < /C>和 txtCase.Text

这给了我一个错误,输入字符串的格式不正确。请帮助我。

根据代码和错误,TextBox控件的文本(txtContact或txtAge)很可能不是有效的整数(整数)值。确保您正在验证输入。您应该使用RequiredFieldValidator以及RangeValidator或RegularExpressionValidator来确保文本框不是空的并且包含有效文本


你也可以考虑使用转换。totIt32.

你将非整数值转换成整数值,请检查<代码> txTACT.Text < /C>和<代码> txtCase.Text < /Cord>及其值,它们应该包含转换成整数值的值。

此代码给了我错误,输入字符串格式不正确。所以请帮帮我。感谢您提前通过调试器运行它,哪一行给出了错误?另外,请查看
Int32.TryParse
()作为
Convert.ToInt32
的替代方法。您是否可以共享为执行任务而传递的值,并发现“输入字符串格式不正确”的错误调试并检查在哪一行出现错误
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = conn;
command.CommandText = "INSERT INTO myTbl ([username],[password],[firstname],[lastname],[mi],[age],[place],[contact])VALUES (?,?,?,?,?,?,?,?)";
command.Parameters.Add("@user", OleDbType.VarChar).Value = txtUsername.Text;
command.Parameters.Add("@psw", OleDbType.VarChar).Value = txtPassword.Text;
command.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text;
command.Parameters.Add("@Lname", OleDbType.VarChar).Value = txtLastName.Text;
command.Parameters.Add("@mIni", OleDbType.VarChar).Value = txtMI.Text;
command.Parameters.Add("@ag", OleDbType.Integer).Value = Convert.ToInt32(txtAge.Text);
command.Parameters.Add("@plc", OleDbType.VarChar).Value = txtPlace.Text;
command.Parameters.Add("@cntct", OleDbType.Integer).Value = Convert.ToInt32(txtContact.Text); ;
command.ExecuteNonQuery();
lblInfo.Visible = true;
lblInfo.Text = "Success";
conn.Close();