尝试从 SQLite VB.NET Windows Universal App 填充组合框
Trying to populate combobox from SQLite VB.NET Windows Universal App
我是 SQLite 的新手,我正在尝试从数据库中填充 Windows 通用应用程序中的组合框。到目前为止我做了以下事情:
With cmbPaciente.Items
Try
Dim sConexao As String = Path.Combine(ApplicationData.Current.LocalFolder.Path, "\Banco\Pronto Facil.db")
Dim aConexao As New SQLite.SQLiteConnection(sConexao)
Dim Comando = aConexao.Execute("select Nome from Dados_Pessoais")
For Each item In Comando
.Add(item)
Next
Catch ex As Exception
.Add("Text 1")
.Add("Text 2")
End Try
End With
我收到这个错误:
BC32023 Expression is of type 'Integer', which is not a collection type.
我明白那是因为 aConexao.Execute 返回的是一个整数,但我还应该怎么做呢?
我使用了错误的方法,这样就可以了:
With cmbPaciente.Items
Dim sConexao As String = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Deal.db")
Dim aConexao As New SQLiteConnection(New SQLitePlatformWinRT(), sConexao)
For Each item As Stockvb In aConexao.Table(Of Stockvb)()
Dim newlist As New Stockvb()
newlist.Id = item.Id
newlist.Symbol = item.Symbol
combolist.Add(newlist)
Next
cmbPaciente.ItemsSource = combolist
End With
这是 Stockvb class:
Public Class Stockvb
<PrimaryKey, AutoIncrement>
Public Property Id() As Integer
Get
Return m_Id
End Get
Set
m_Id = Value
End Set
End Property
Private m_Id As Integer
<MaxLength(8)>
Public Property Symbol() As String
Get
Return m_Symbol
End Get
Set
m_Symbol = Value
End Set
End Property
Private m_Symbol As String
结束Class
特别感谢 Grace Feng - MSFT
我是 SQLite 的新手,我正在尝试从数据库中填充 Windows 通用应用程序中的组合框。到目前为止我做了以下事情:
With cmbPaciente.Items
Try
Dim sConexao As String = Path.Combine(ApplicationData.Current.LocalFolder.Path, "\Banco\Pronto Facil.db")
Dim aConexao As New SQLite.SQLiteConnection(sConexao)
Dim Comando = aConexao.Execute("select Nome from Dados_Pessoais")
For Each item In Comando
.Add(item)
Next
Catch ex As Exception
.Add("Text 1")
.Add("Text 2")
End Try
End With
我收到这个错误:
BC32023 Expression is of type 'Integer', which is not a collection type.
我明白那是因为 aConexao.Execute 返回的是一个整数,但我还应该怎么做呢?
我使用了错误的方法,这样就可以了:
With cmbPaciente.Items
Dim sConexao As String = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Deal.db")
Dim aConexao As New SQLiteConnection(New SQLitePlatformWinRT(), sConexao)
For Each item As Stockvb In aConexao.Table(Of Stockvb)()
Dim newlist As New Stockvb()
newlist.Id = item.Id
newlist.Symbol = item.Symbol
combolist.Add(newlist)
Next
cmbPaciente.ItemsSource = combolist
End With
这是 Stockvb class:
Public Class Stockvb
<PrimaryKey, AutoIncrement>
Public Property Id() As Integer
Get
Return m_Id
End Get
Set
m_Id = Value
End Set
End Property
Private m_Id As Integer
<MaxLength(8)>
Public Property Symbol() As String
Get
Return m_Symbol
End Get
Set
m_Symbol = Value
End Set
End Property
Private m_Symbol As String
结束Class
特别感谢 Grace Feng - MSFT