oledbeexception未被用户代码处理.错误信息:OverFlow



输入图像描述在这里输入图像描述在这里我试图插入数据到我的MS Access数据库。My table's name .

cmd.Parameters.Add("@name", OleDbType.VarChar).Value = txtNameSignUp.Text;
cmd.Parameters.Add("@surname", OleDbType.VarChar).Value = txtSurnameSignUp.Text;
cmd.Parameters.Add("@phone", OleDbType.VarChar).Value = txtPhoneSignUp.Text;
cmd.Parameters.Add("@mail", OleDbType.VarChar).Value = txtMailSignUp.Text;
cmd.Parameters.Add("@address", OleDbType.VarChar).Value = txtAddressSignUp.Text;
cmd.Parameters.Add("@username", OleDbType.VarChar).Value = txtUserNameSignUp.Text;
cmd.Parameters.Add("@password", OleDbType.VarChar).Value = txtPasswordSignUp.Text;
cmd.ExecuteNonQuery();
cnn.Close();
cnn = null;

我尝试(OleDBType.Binary).Value = Convert.ToByte(txtPhoneSignUp.Text);为电话的文本框,但它说"太大"或"太小"。

sorgu = "INSERT INTO注册([名字],[姓氏],(电话),【邮件】,【地址】,【用户名】,【密码】)值(@ name, @surname @phone @mail, @ address, @用户名,@password);";cmd = new OleDbCommand(sorgu, cnn);

        //cmd.Parameters.AddWithValue("@name", txtNameSignUp.Text);
        //cmd.Parameters.AddWithValue("@surname", txtSurnameSignUp.Text);
        //cmd.Parameters.AddWithValue("@phone", Convert.ToDouble(txtPhoneSignUp.Text));
        //cmd.Parameters.AddWithValue("@mail", txtMailSignUp.Text);
        //cmd.Parameters.AddWithValue("@address", txtAddressSignUp.Text);
        //cmd.Parameters.AddWithValue("@username", txtUserNameSignUp.Text);
        //cmd.Parameters.AddWithValue("@password", txtPasswordSignUp.Text);
        cmd.Parameters.Add("@name", OleDbType.VarChar).Value = txtNameSignUp.Text;
        cmd.Parameters.Add("@surname", OleDbType.VarChar).Value = txtSurnameSignUp.Text;
        cmd.Parameters.Add("@phone", OleDbType.VarChar).Value = 
        cmd.Parameters.Add("@mail", OleDbType.VarChar).Value = txtMailSignUp.Text;
        cmd.Parameters.Add("@address", OleDbType.VarChar).Value = txtAddressSignUp.Text;
        cmd.Parameters.Add("@username", OleDbType.VarChar).Value = txtUserNameSignUp.Text;
        cmd.Parameters.Add("@password", OleDbType.VarChar).Value = txtPasswordSignUp.Text;
            cmd.ExecuteNonQuery();
            cnn.Close();
            cnn = null;

for OleDBType。二进制你需要一个字节[],所以把你的代码改成

Encoding.ASCII.GetBytes (txtPhoneSignUp.Text)

相关内容

  • 没有找到相关文章

最新更新