Database 需要Visual Basic程序中的帮助吗

Database 需要Visual Basic程序中的帮助吗,database,vb.net,Database,Vb.net,我试图在VB中修复此代码,但出现以下错误: 严重性:错误 代码:BC30516 描述:重载解析失败,因为没有可访问的“值”接受此数量的参数。 项目:没有代码的数据库 文件:C:\Users\Sam\Dropbox\University Work\VisualBasic\Database Without Code\Database Without Code\Database.vb 行:101 抑制状态:激活 我该如何解决这个问题 Public Class Database Private

我试图在VB中修复此代码,但出现以下错误:

严重性:错误
代码:BC30516
描述:重载解析失败,因为没有可访问的“值”接受此数量的参数。
项目:没有代码的数据库
文件:C:\Users\Sam\Dropbox\University Work\VisualBasic\Database Without Code\Database Without Code\Database.vb
行:101
抑制状态:激活

我该如何解决这个问题

Public Class Database

    Private m_cnADOConnection As New ADODB.Connection
    Private m_rstAddress As New ADODB.Recordset

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        m_cnADOConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source= AddressBook.mdb") ' connects and sets path for database
        m_rstAddress.Open("tblContacts", m_cnADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
        ShowCurrentRecord() 'calls a method to fill the record set
        Me.WindowState = FormWindowState.Normal ' opens form in different states


    End Sub



    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        ShowCurrentRecord()
        Dim Search As String
        Dim SearchLoop As Boolean = False ' sets the loop control 
        Search = InputBox("Enter Surname: ", "Search")
        m_rstAddress.MoveFirst() ' set db to start of file

        If IsNumeric(Search) Then
            MessageBox.Show("Invalid Data: Surname must not be numeric", "Invalid Data")
            Exit Sub ' check that valid entry has been made
        End If
        Do While SearchLoop = False
            If m_rstAddress.EOF() Then
                MessageBox.Show("No Matching Records Found !", "Nil Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                SearchLoop = True
            ElseIf Search = CStr(m_rstAddress.Fields("Surname").Value) Then
                ShowCurrentRecord()
                SearchLoop = True
            Else
                m_rstAddress.MoveNext()
            End If

        Loop
    End Sub

    Private Sub ShowCurrentRecord()

        If m_rstAddress.BOF Or m_rstAddress.EOF Then
            txtFirstName.Text = ""
            txtLastName.Text = ""
            txtAddress1.Text = ""
            txtAddress2.Text = ""
            txtAddress3.Text = ""
            txtPostCode.Text = ""
            txtPhone.Text = ""
            txtEmail.Text = ""
            txtNotes.Text = ""
            Exit Sub
        End If


        txtFirstName.Text = CStr(m_rstAddress.Fields("FirstName").Value) ' the following assigns the text box the value from the DB
        txtLastName.Text = CStr(m_rstAddress.Fields("Surname").Value)
        txtAddress1.Text = CStr(m_rstAddress.Fields("Address1").Value)
        txtAddress2.Text = CStr(m_rstAddress.Fields("Address2").Value)
        txtAddress3.Text = CStr(m_rstAddress.Fields("Address3").Value)
        txtPostCode.Text = CStr(m_rstAddress.Fields("Postcode").Value)
        txtPhone.Text = CStr(m_rstAddress.Fields("Phone").Value)
        txtEmail.Text = CStr(m_rstAddress.Fields("Email").Value)
        txtNotes.Text = CStr(m_rstAddress.Fields("Notes").Value)


    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click


        txtFirstName.Text = ""
        txtLastName.Text = ""
        txtAddress1.Text = ""
        txtAddress2.Text = ""
        txtAddress3.Text = ""
        txtPostCode.Text = ""
        txtPhone.Text = ""
        txtEmail.Text = ""
        txtNotes.Text = ""
        MessageBox.Show("Please enter the details in the boxes then click Save Record", "Instructions")


    End Sub



    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click


        m_rstAddress.AddNew()

        m_rstAddress.Fields("FirstName").Value = txtFirstName.Text
        m_rstAddress.Fields("Surname").Value = txtLastName.Text
        m_rstAddress.Fields("Address1").Value = txtAddress1.Text
        m_rstAddress.Fields("Address2").Value = txtAddress2.Text
        m_rstAddress.Fields("Address3").Value = txtAddress3.Text
        m_rstAddress.Fields("Phone").Value(-lblPhone.Text)


    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        m_rstAddress.AddNew()

        m_rstAddress.Fields("FirstName").Value = txtFirstName.Text
        m_rstAddress.Fields("Surname").Value = txtLastName.Text
        m_rstAddress.Fields("Address1").Value = txtAddress1.Text
        m_rstAddress.Fields("Address2").Value = txtAddress2.Text
        m_rstAddress.Fields("Address3").Value = txtAddress3.Text
        m_rstAddress.Fields("Postcode").Value = txtPostCode.Text
        m_rstAddress.Fields("Phone").Value = txtPhone.Text
        m_rstAddress.Fields("Email").Value = txtEmail.Text
        m_rstAddress.Fields("Notes").Value = txtNotes.Text
        m_rstAddress.Update()
        ShowCurrentRecord()
        If m_rstAddress.EOF Then
            m_rstAddress.MoveFirst()
            ShowCurrentRecord()
        Else : m_rstAddress.MoveFirst()
            ShowCurrentRecord()
        End If


        m_rstAddress.Update()
        ShowCurrentRecord()
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub



    Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
        If m_rstAddress.BOF Then
            MessageBox.Show("You have reached the begninning of the file.", "BOF")
            m_rstAddress.MoveFirst()
            ShowCurrentRecord()
        Else : m_rstAddress.MoveFirst()
            ShowCurrentRecord()
Elsee:      m_rstAddress.MovePrevious()
            ShowCurrentRecord()
        End If

    End Sub

    Private Sub btnPrevious_Click(sender As System.Object, e As System.EventArgs) Handles btnPrevious.Click
        If m_rstAddress.BOF Then

            MessageBox.Show("You have reached the end of this file.")
            m_rstAddress.MoveFirst()
            ShowCurrentRecord()
        Else : m_rstAddress.MovePrevious()
            ShowCurrentRecord()

        End If
    End Sub


    Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
        If m_rstAddress.BOF Then
            m_rstAddress.MoveLast()
            ShowCurrentRecord()
        Else : m_rstAddress.MoveLast()
            ShowCurrentRecord()


        End If
    End Sub



End Class

该错误表示此行不正确:

m_rstAddress.Fields("Phone").Value(-lblPhone.Text)
该字段的设置方式是否应与其他字段相同

m_rstAddress.Fields("Phone").Value = lblPhone.Text

如果你真的指出了它失败的地方,这会有所帮助。它无法运行程序。好的,但它会在某个特定点失败,如果它在构建过程中失败,错误窗口会告诉你在哪里,如果它在执行过程中失败,那么你将有一个堆栈跟踪。查看堆栈跟踪,然后查看内部细节。这应该告诉你它失败的地方。如果我们知道有更多的机会,我们可能能够提供帮助。如果你可以削减代码到最低限度,这将有助于我们也。它可能会给你一个问题所在的线索。错误在这一行上-m_rstAddress.Fields(“Phone”).Value(-lblPhone.Text)-如果你仔细阅读问题,这一行就包括了。它还指向标签,而不是文本框,这在我看来有点奇怪。所以也许它甚至应该是txtPhone.Text。非常确定取值参数没有过载。这可以解释这个错误。