0
我的代碼:VB.NET公共 '添加' 錯誤
Imports System.Data.OleDb
Public Class DBase
Dim conn As New OleDbConnection
Dim myqry As String = Nothing
Dim mycmd As New OleDbCommand
Dim mydr As OleDbDataReader
Dim str As String = Nothing
Dim objCmd As New OleDb.OleDbCommand
Private Sub DBase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call LVsettings()
Call ConnToDB()
Call FillListview()
Call Set1()
End Sub
#Region "FillListView"
Sub FillListview()
LV.Items.Clear()
myqry = "SELECT * from Accounts ORDER BY YrandSec,FirstName Asc"
mycmd = New OleDbCommand(myqry, conn)
mydr = mycmd.ExecuteReader
While mydr.Read
With LV
.Items.Add(mydr("Number"))
With .Items(.Items.Count - 1).SubItems
.Add(mydr("StudNo"))
.Add(mydr("FirstName"))
.Add(mydr("LastName"))
.Add(mydr("YrandSec"))
.Add(mydr("Exer1")) - Error occurs here
.Add(mydr("Exer2"))
.Add(mydr("Exer3"))
.Add(mydr("Exer4"))
.Add(mydr("Exer5"))
End With
End With
End While
End Sub
#End Region
錯誤:
ERROR - (Overload resolution failed because no Public 'Add' can be called with these arguments:
'Public Function Add(text As String) As System.Windows.Forms.ListViewItem.ListViewSubItem':
Argument matching parameter 'text' cannot convert from 'DBNull' to 'String'.
'Public Function Add(item As System.Windows.Forms.ListViewItem.ListViewSubItem) As System.Windows.Forms.ListViewItem.ListViewSubItem':
Argument matching parameter 'item' cannot convert from 'DBNull' to 'ListViewSubItem'.)