VB.netでツリービューを作成しようとしていますが、MSAccess 2010データベースからデータを読み込む必要があります。このプログラムを実行しようとすると、エラーが発生します。引数Null例外が処理されなかったため、 'column'引数はNULLになりませんプログラムがクラッシュします。ここでは、コードは次のとおりです。VB.netエラー 'Null例外が処理されず、列の引数がnullになりません'
Imports System.Data.OleDb
Public Class frmRating
Private Sub frmRating_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Database Connections and Datasets
Dim DSRating As DataSet
Dim CNRating As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\BlockHeadDatabase.accdb;Persist Security Info=False;")
'DataAdapters to hold records
Dim DARatings As New OleDb.OleDbDataAdapter("SELECT Rating FROM Rating", CNRating)
Dim DATitle As New OleDb.OleDbDataAdapter("SELECT Title, Lending_Class FROM Title Order By Title", CNRating)
Dim DADVD As New OleDb.OleDbDataAdapter("SELECT DVD_NO, Branch_Code FROM DVD", CNRating)
'Instantiate the datasets, open the connection and fill the dataAdapters from the table
DSRating = New DataSet()
CNRating.Open()
DARatings.Fill(DSRating, "Rating")
DATitle.Fill(DSRating, "Title")
DADVD.Fill(DSRating, "DVD")
'Close the connection to the data store, free up the resources
CNRating.Close()
'Create a data relation objects between the data tables
DSRating.Relations.Add("RatingtoTitle", DSRating.Tables("Rating").Columns("Rating"), DSRating.Tables("Title").Columns("Rating"))
DSRating.Relations.Add("TitletoDVD", DSRating.Tables("Title").Columns("Title"), DSRating.Tables("DVD").Columns("Title"))
Dim relation As DataRelation
Dim table1Column As DataColumn
Dim table2Column As DataColumn
'retrieve the column
table1Column = DSRating.Tables("Rating").Columns("Rating")
table2Column = DSRating.Tables("Title").Columns("Rating")
'Create a data relation objects between the data tables
relation = New DataRelation("relation", table1Column, table2Column)
DSRating.Relations.Add(relation)
DSRating.Relations.Add("RatingtoTitle", DSRating.Tables("Rating").Columns("Rating"), DSRating.Tables("Title").Columns("Rating"))
Try
DSRating.Relations.Add("RatingtoTitle", DSRating.Tables("tblVehicle").Columns("Rego_No"), DSRating.Tables("tblRental").Columns("Rego_No"))
MsgBox("Data relation completed")
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
End Sub
End Class
あなたは私たちに、エラーの行番号を提供することはできますか? – GianT971