我在写一个vb查询oracle程序时发现一个问题,就是单个执行select语句时都能通过,而使用union all时一直报错:
strdb="select .................. from table1 where .........." _
&" union all " _
&" select b ....................from table2 where ......"
一会儿说表达式不匹配,一会儿说select语句没有结束,请教各位该怎么改啊
strdb="select .................. from table1 where .........." _
&" union all " _
&" select b ....................from table2 where ......"
一会儿说表达式不匹配,一会儿说select语句没有结束,请教各位该怎么改啊
解决方案 »
- 我们公司是本地公网运营商,想做光缆资源管理系统
- 如何读取一个文本里的前32个数据作为Y值打印曲线
- VB菜单中实现单选菜单怎样实现?VB菜单中在最右边放置一个位图如何做,象IE一样?
- 今天老爸生日,散个分,祝贺下
- 一个关于COM+的奇怪问题,望高手给予指点!!
- 关于中大型的Vb程序退出的问题,请大家讨论一下
- 急啊!菜鸟等通宵呀!打包后就是不能安装!!!
- 简单问题,来者有分?
- IIS为什么只能执行HTML文件不能执行ASP文件,请教
- 有人知道那能下载WIN CE或开发过它得程序?高手们别吵了,进来谈谈!
- mshflexgrid控件能否显示check按钮那个打勾的功能?我用list只能是一列。如果实现一行多列能勾选?
- 二维数组的排序算法
sql贴的不全怎么帮你改?
Private Sub Command1_Click()Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set MSHFlexGrid1.DataSource = Nothingd1 = DTPicker1.Value
d2 = DTPicker2.Value
'MSHFlexGrid1.BackColor = RGB(230, 230, 230)cn.CursorLocation = adUseClient
cn.Open "Provider=MSDAORA.1;Password=ic6279admin;User ID=ICADMIN;Data Source=ORAISSUE;Persist Security Info=True"If d1 > d2 Then
MsgBox ("error 开始日期必须小于结束日期")
Exit Sub
Else
strdb = "select name, id, card, balance, vailddate from usercard where updateto_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')" _
& "union all " _
& "select balance name, id, card, balance, vailddate from usercard where loddate=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')"
End Ifrs.Open strdb, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Set MSHFlexGrid1.DataSource = rsrs.Close
cn.Close
End Sub
& " union all " _
& "select balance name, id, card, balance, vailddate from usercard where loddate=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')"
& "union all " _
& "select balance name, id, card, balance, vailddate from usercard where loddate=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')"
& "union all " _
& "select balance name, id, card, balance, vailddate from usercard where loddate=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')"
Dim strdb As String d1 = "2008-11-15"
strdb = ""
strdb = strdb & "select name, id, card, balance, vailddate " & vbNewLine
strdb = strdb & " from usercard " & vbNewLine
strdb = strdb & " where update=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')" & vbNewLine
strdb = strdb & "union all " & vbNewLine
strdb = strdb & "select balance name, id, card, balance, vailddate " & vbNewLine
strdb = strdb & " from usercard " & vbNewLine
strdb = strdb & " where loddate=to_date('" & Format(d1, "yyyy-mm-dd") & "','yyyy-mm-dd')"
Debug.Print strdbEnd Subselect name, id, card, balance, vailddate
from usercard
where update=to_date('2008-11-15','yyyy-mm-dd')
union all
select balance name, id, card, balance, vailddate
from usercard
where loddate=to_date('2008-11-15','yyyy-mm-dd')