vb 连 ACCESS 判断记录集是否为空
Adodc1.RecordSource="selectabcfromdddd"Adodc1.RefreshIfAdodc1.Recordset.RecordCount<>...
Adodc1.RecordSource = "select abc from dddd "
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
……
endif
这样可以判断有没有数据,但是我要做统计,如果改写成
Adodc1.RecordSource = "select sum(abc) from dddd where dkd='C'"
这时RecordCount 就判断不了了,在符合dkd='C'条件情况下本来数据库中没有的,但是RecordCount 返回的值一样是1,当数据库中只有一条数据符合条件,他也返回1,,,那有没有其它方法可能解决呢?
第一行语句写少了 where dkd='C'"
fjxiaoluo 可能没留意我说,我改了之后需要做统计
select sum(abc) from dddd where dkd='C'
主要就是 sum(abc) 这里影响 RecordCount 返回值 展开
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
……
endif
这样可以判断有没有数据,但是我要做统计,如果改写成
Adodc1.RecordSource = "select sum(abc) from dddd where dkd='C'"
这时RecordCount 就判断不了了,在符合dkd='C'条件情况下本来数据库中没有的,但是RecordCount 返回的值一样是1,当数据库中只有一条数据符合条件,他也返回1,,,那有没有其它方法可能解决呢?
第一行语句写少了 where dkd='C'"
fjxiaoluo 可能没留意我说,我改了之后需要做统计
select sum(abc) from dddd where dkd='C'
主要就是 sum(abc) 这里影响 RecordCount 返回值 展开
4个回答
展开全部
建议改用代码而不用adodc,代码如下:
dim sjlj as New ADODB.Connection
sjlj.ConnectionString =adocd1.connectionstring
Dim ss As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim zj As Integer
sjlj.Open
Set cmd.ActiveConnection = sjlj
cmd.CommandText = "select abc from dddd where dkd='C'"
ss.CursorType = adOpenKeyset
ss.Open cmd
zj = ss.RecordCount
sjlj.Close
变量zj就是符合条件的总数。
dim sjlj as New ADODB.Connection
sjlj.ConnectionString =adocd1.connectionstring
Dim ss As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim zj As Integer
sjlj.Open
Set cmd.ActiveConnection = sjlj
cmd.CommandText = "select abc from dddd where dkd='C'"
ss.CursorType = adOpenKeyset
ss.Open cmd
zj = ss.RecordCount
sjlj.Close
变量zj就是符合条件的总数。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
判断Adodc1.Recordset.Fields(0)里的值(还是Fields(1)?记不清。),就是聚集函数查询返回的值,是0就表示没有符合条件的记录。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Imperiet的 Dum Dum Dollar Djungel的简写
Imperiet - D-D-D-D (Dum Dum Dollar Djungel)
D-D-D-D (Dum Dum Dollar Djungel)
The jungle drums will call you all
Ooooh....
Dum-dum-dollar-djungel sover aldrig sött
den vackraste mardröm som du mött
Dum-dum-dollar-djungel cocainekuvös
allting som du aldrig behövt
Ooooh....
Dum-dum-dollar-djungel bubbelgumblues
Här kokar bensinen i ditt blod
Dum-dum-dollar-djungel TV-terrorland
Allting som du aldrig trodde fanns
Ooooh....
Dum-dum-dollar-djungel frihetsfabrik
Dum-dum-dollar-djungel cocainekuvös
Dum-dum-dollar-djungel
Dum-dum-dollar-djungel graffitigatorsglam
Dum-dum-dollar-djungel
The jungle drums will call you all
come and watch the rise and fall
Dum-dum-dollar-djungel
Dum-dum-dollar-djungel 48 timmars dygn
Dum-dum-dollar-djungel heroinservice limousineservice
Dum-dum-dollar-djungel
Imperiet - D-D-D-D (Dum Dum Dollar Djungel)
D-D-D-D (Dum Dum Dollar Djungel)
The jungle drums will call you all
Ooooh....
Dum-dum-dollar-djungel sover aldrig sött
den vackraste mardröm som du mött
Dum-dum-dollar-djungel cocainekuvös
allting som du aldrig behövt
Ooooh....
Dum-dum-dollar-djungel bubbelgumblues
Här kokar bensinen i ditt blod
Dum-dum-dollar-djungel TV-terrorland
Allting som du aldrig trodde fanns
Ooooh....
Dum-dum-dollar-djungel frihetsfabrik
Dum-dum-dollar-djungel cocainekuvös
Dum-dum-dollar-djungel
Dum-dum-dollar-djungel graffitigatorsglam
Dum-dum-dollar-djungel
The jungle drums will call you all
come and watch the rise and fall
Dum-dum-dollar-djungel
Dum-dum-dollar-djungel 48 timmars dygn
Dum-dum-dollar-djungel heroinservice limousineservice
Dum-dum-dollar-djungel
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询