我試圖修復VB這個代碼,我得到以下錯誤:需要幫助的Visual Basic程序
Severity: Error
Code: BC30516
Description: Overload resolution failed because no accessible 'Value' accepts this number of arguments.
Project: Database Without Code
File: C:\Users\Sam\Dropbox\University Work\VisualBasic\Database Without Code\Database Without Code\Database.vb
Line: 101
Suppression State: Active
我該如何解決這個問題?
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
如果你真的指出它失敗的地方,這將有所幫助。 –
它無法運行程序。 – Samlaptop
好的,但它會在特定點失敗,如果它在構建過程中失敗,錯誤窗口會告訴你在哪裏,如果它在執行期間失敗,那麼你將有一個堆棧跟蹤。查看堆棧跟蹤,然後查看內部細節。這應該告訴你它失敗的地方。如果我們知道我們可以提供更多幫助的機會。 –