联合查询

G36822 G36822 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
数据库用的是ACCESS,查询语句在ACCESS中正常,但在VB.NET中提示“其他信息: ORDER BY 子句语法错误。”
代码如下:
    Private Sub FillCustomersAccounts()
strCustomersAccountsSQL = "Select Customer, EarningDate as AccountDate, Description as Desc, Amount as DR, 0 as CR From " &
"tblCustomersEarns Where EarningDate Between #2014-1-1# And #2014-1-31# " &
"UNION ALL Select Customer, OrderDate as AccountDate, Remark as Desc, 0 as DR, Account as CR From " &
"S:\Order.accdb.tblOrder Where OrderDate Between #2014-1-1# And #2014-1-31#"
conCustomer.Open()
Dim CustomersAccountsDataAdapt As New OleDb.OleDbDataAdapter(strCustomersAccountsSQL, conCustomer)
Dim CustomersAccountsDataset As New DataSet
CustomersAccountsDataAdapt.Fill(CustomersAccountsDataset, "CustomersAccounts")
dgvCustomerAccount.DataSource = CustomersAccountsDataset
dgvCustomerAccount.DataMember = "CustomersAccounts"
conCustomer.Close()
End Sub


求大神正解。
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
G36822
VB 16,718 成员 110,520 内容