尝试将数据添加到我的数据库时出现溢出错误(VB.NET& MS ACCESS) [英] Overflow error when I try to adding data into my database (VB.NET & MS ACCESS)

查看:119
本文介绍了尝试将数据添加到我的数据库时出现溢出错误(VB.NET& MS ACCESS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的错误屏幕截图



照片 - Google+ [ ^ ]



我尝试过:



这是我当前表单的代码片段



here is my screenshot of the error

Photo - Google+[^]

What I have tried:

here is my code snippet of the current form

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox1.Text & TextBox2.Text & TextBox3.Text & TextBox4.Text & TextBox5.Text & TextBox6.Text & TextBox7.Text = Nothing Then
            MsgBox("Please fill up all information.")
            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
            TextBox5.Clear()
            TextBox6.Clear()
            TextBox7.Clear()
        Else
            Try
                Dim myConnection As OleDbConnection
                myConnection = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=G:\Sem7 (Final Project)\Bookstore POS System\possys.mdb;Persist Security Info=false;")
                Dim myCommand As OleDbCommand
                myCommand = New OleDbCommand("INSERT INTO customer([ID],[c_name],[email],[phone],[nric],[sex],[race]) VALUES (@ID, @c_name, @email, @phone, @nric, @sex, @race)", myConnection)
                Dim id As New OleDbParameter("@ID", OleDbType.VarChar)
                Dim name As New OleDbParameter("@c_name", OleDbType.VarChar)
                Dim email As New OleDbParameter("@email", OleDbType.VarChar)
                Dim phone As New OleDbParameter("@phone", OleDbType.VarChar)
                Dim nric As New OleDbParameter("@nric", OleDbType.VarChar)
                Dim sex As New OleDbParameter("@sex", OleDbType.VarChar)
                Dim race As New OleDbParameter("@race", OleDbType.VarChar)
                id.Value = TextBox1.Text
                name.Value = TextBox2.Text
                email.Value = TextBox3.Text
                phone.Value = TextBox4.Text
                nric.Value = TextBox5.Text
                sex.Value = TextBox6.Text
                race.Value = TextBox7.Text
                myCommand.Parameters.Add(id)
                myCommand.Parameters.Add(name)
                myCommand.Parameters.Add(email)
                myCommand.Parameters.Add(phone)
                myCommand.Parameters.Add(nric)
                myCommand.Parameters.Add(sex)
                myCommand.Parameters.Add(race)
                myCommand.Connection.Open()
                myCommand.ExecuteNonQuery()
                myCommand.Dispose()
                MsgBox("Account Created", MsgBoxStyle.Information, "Registered!")
                myConnection.Close()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If
    End Sub

推荐答案

当您尝试将数值插入/更新到该数据类型范围之外的某些内容时,会导致溢出错误。

不知道架构您的表格以及插入的数据很难回答。提供该信息,我可以更新答案。
Overflow errors are caused when you try to insert/update a numeric value to something outside of that data-types range.
Without knowing the schema of your table as well as the data being inserted, it is hard to answer. Provide that information and I can update the answer.


这篇关于尝试将数据添加到我的数据库时出现溢出错误(VB.NET& MS ACCESS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆