Unhandled exception of type SqlServerCe.SqlCeException
Ved exekvering af programmet opstår følgende fejl:"An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException'
occurred in System.Data.SqlServerCe.dll"
og programmet stopper efterfølgende på linien:
adapter.Fill(dataSet)
Hvad gør jeg galt???
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents DataGrid As System.Windows.Forms.DataGrid
Private Const DATABASE As String = "Data Source=\My
Documents\ATdata.sdf; Password='r2d2'"
Public Sub New()
MyBase.New()
InitializeComponent()
Dim conn As SqlServerCe.SqlCeConnection = New
SqlServerCe.SqlCeConnection(DATABASE)
Dim adapter As SqlServerCe.SqlCeDataAdapter = New
SqlServerCe.SqlCeDataAdapter
Dim query As String = "SELECT Preis, TopLfd, TopVor, Bezeichnung,
Menge FROM MyTable"
adapter.SelectCommand = New SqlServerCe.SqlCeCommand(query, conn)
Dim dataSet As DataSet = New DataSet
adapter.Fill(dataSet)
DataGrid.DataSource = dataSet.Tables(0)
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
Private Sub InitializeComponent()
Me.DataGrid = New System.Windows.Forms.DataGrid
'
'DataGrid
'
Me.DataGrid.Size = New System.Drawing.Size(248, 264)
Me.DataGrid.Text = "DataGrid"
'
'Form1
'
Me.ClientSize = New System.Drawing.Size(234, 295)
Me.Controls.Add(Me.DataGrid)
Me.Text = "SQL Server CE"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
End Sub
Public Shared Sub Main()
Application.Run(New Form1())
End Sub
#End Region
End Class