我用SQL查询出一个值,怎样得到现在RS游标所在的行数或是ID值
如图PublicSubsameshift()DimstrSQLSAsStringDimrsSAsRecordsetSetrsS=NewRecordsetDimCSameA...
如图
Public Sub sameshift() Dim strSQLS As String Dim rsS As Recordset Set rsS = New Recordset Dim CSame As Variant Dim CurID As Variant strSQLS = "SELECT [Morningshift]" strSQLS = strSQLS & "FROM [DateAndShift] " strSQLS = strSQLS & "WHERE [Morningshift]= [Nightshift] And [Date]>#2015-6-15# and [Date]<#2015-7-16# And [Nightshift]='B'And [Morningshift]='B' " rsS.Open strSQLS, g_conn, adOpenForwardOnly, adLockReadOnly, adCmdText CSame = rsS.RecordCount rsS.MoveFirst CurID =rss. ' 请问这儿应该怎么写??我就是想怎么通过rss来得到目前所在的ID Set rsS = Nothing End Sub
就如上数据库中的11和13行
我要的结果是返回CurID=11 或 13
我现在有一新问题
Dim strSQLMA As String
Dim rsmA As Recordset
Set rsmA = New Recordset
Dim UMorningshift As Variant
Dim UNightshift As Variant
CurID = rsS("ID")
CurIDJ = CurID - 1
strSQLMA = "SELECT [Morningshift],[Nightshift]"
strSQLMA = strSQLMA & "FROM [DateAndShift] "
strSQLMA = strSQLMA & "WHERE [ID]=CurID - 1"
rsmA.Open strSQLMA, g_conn, adOpenForwardOnly, adLockReadOnly, adCmdText
为什么运行不起,
但是如果我把CurID - 1换成具体数字,比如10就能运行,可是我的这个数是个可变的,所以不能用定值,请问我的表达错在那儿, 展开
Public Sub sameshift() Dim strSQLS As String Dim rsS As Recordset Set rsS = New Recordset Dim CSame As Variant Dim CurID As Variant strSQLS = "SELECT [Morningshift]" strSQLS = strSQLS & "FROM [DateAndShift] " strSQLS = strSQLS & "WHERE [Morningshift]= [Nightshift] And [Date]>#2015-6-15# and [Date]<#2015-7-16# And [Nightshift]='B'And [Morningshift]='B' " rsS.Open strSQLS, g_conn, adOpenForwardOnly, adLockReadOnly, adCmdText CSame = rsS.RecordCount rsS.MoveFirst CurID =rss. ' 请问这儿应该怎么写??我就是想怎么通过rss来得到目前所在的ID Set rsS = Nothing End Sub
就如上数据库中的11和13行
我要的结果是返回CurID=11 或 13
我现在有一新问题
Dim strSQLMA As String
Dim rsmA As Recordset
Set rsmA = New Recordset
Dim UMorningshift As Variant
Dim UNightshift As Variant
CurID = rsS("ID")
CurIDJ = CurID - 1
strSQLMA = "SELECT [Morningshift],[Nightshift]"
strSQLMA = strSQLMA & "FROM [DateAndShift] "
strSQLMA = strSQLMA & "WHERE [ID]=CurID - 1"
rsmA.Open strSQLMA, g_conn, adOpenForwardOnly, adLockReadOnly, adCmdText
为什么运行不起,
但是如果我把CurID - 1换成具体数字,比如10就能运行,可是我的这个数是个可变的,所以不能用定值,请问我的表达错在那儿, 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询