我尝试使用ole db参数创建数据集并填充其中的数据表之一,但是它仅加载列标题,而内部没有任何内容。通过制作新的查询向导在访问中对其进行测试时,它将正确加载
Dim b As String = txtkensaku.Text
query = " SELECT O.取引番号 AS [Transaction#], P.商品コード AS
ProductCode, P.商品名前 AS Product, P.[カテゴリー] AS カテゴリ, O.販
売日 AS TransactionDate, O.販売数量 AS Quantity, O.販売値段
FROM 販売テーブル AS O, 商品 AS P WHERE (((P.商品コード) Like '" & b
& "*') AND ((O.商品コード参照)=[P].[商品コード]))"
Dim a As New 接続クラス
con_open()
Dim adapter As New OleDbDataAdapter("SELECT O.取引番号 AS
[Transaction#], P.商品コード AS ProductCode, P.商品名前 AS Product,
P.[カテゴリー] AS カテゴリ, O.販売日 AS TransactionDate, O.販売数量 AS
Quantity, O.販売値段
FROM 販売テーブル AS O, 商品 AS P WHERE (((P.商品コード) Like '" & b
& "*') AND ((O.商品コード参照)=[P].[商品コード]))", accconection)
Dim ass As New DataSet
adapter.FillSchema(ass, SchemaType.Source, "Customers")
adapter.Fill(ass, "Customers")
Dim k As DataTable = ass.Tables("Customers")
DG1.ItemsSource = k.DefaultView
accconection是数据库的连接
Public strcon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Tmp\wpf1.accdb"
Public accconection As New OleDbConnection(strcon)
con_open函数以打开
Public Function con_open() As Boolean
accconection.Close()
Try
accconection.Open()
Catch oledbex As OleDbException
MessageBox.Show(oledbex.Message, "エラー")
Return False
Catch invalidoperationexceptionerr As InvalidOperationException
MessageBox.Show(invalidoperationexceptionerr.Message, "エラー")
Return False
End Try
If accconection.State <> ConnectionState.Open Then
MessageBox.Show("データベース接続に失敗しました")
Return False
Else
Return True
End If
End Function
我想念一些关键的步骤吗?
我也使用这种方法通过“ select”语句填充表,并且效果很好
这是在访问中正确加载 但是在数据集中什么也没显示