|
-
Jul 2nd, 2004, 03:51 PM
#1
Thread Starter
Lively Member
sql statement
Hi:
Can someone please tell me what is I am doing wrong with this statement. The statement is returning 0 and I know there are at least 100 records in my table.
I think the problem is with the date. I am not be converting the date to its proper datatype.
lcsql = "Select * from TaxName Where Meeting_ID= " & _
Chr(39) & Trim(Str(iMeeting_ID)) & Chr(39) & _
" And Event_Date =" & "02/02/2004"
oRecData.Open lcsql, oDataConn
x= oRecData.RecordCount
-
Jul 3rd, 2004, 03:52 PM
#2
Probably because you are not specifing the cursor type and lock
type. The default cursor type is FowardOnly when it is not
specified. This will make the RecordCount property reflect a -1
because the RecordCount property is not supported with a
FowardOnly cursor type. Change to Keyset or Static.
To test for records with any type of cursor, use this...
VB Code:
oRecData.Open lcsql, oDataConn, adOpenKeyset, adLockOptimistic, adCmdText
If oRecData.BOF = False and oRecData.EOF = False Then
'Do record manipulation or ???
Else
MsgBox "No Records Returned!", vbOkOnly+vbInformation, App.ProductName
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 6th, 2004, 09:35 AM
#3
Thread Starter
Lively Member
sql statement
The statement below does return records if I do not include date. For example:
lcsql = "Select * from TaxName Where Meeting_ID= " & _
Chr(39) & Trim(Str(iMeeting_ID)) & Chr(39)
The problem is when I include the date. Why does it not like the date?
lcsql = "Select * from TaxName Where Meeting_ID= " & _
Chr(39) & Trim(Str(iMeeting_ID)) & Chr(39) & _
" And Event_Date =" & "02/02/2004"
Thanks
-
Jul 6th, 2004, 10:14 AM
#4
Thread Starter
Lively Member
resolved:sql statement
Thanks all:
I figured out what was the issue. I needed to add extra digit if the month value 2 needed to be (02).
Thanks again
-
Jul 6th, 2004, 10:17 AM
#5
What is the field definition for Event_Date?
If it is text then enclose the date with apostrophies. If it is
formatted as a Date/Time filed, then try adding the pound
character around your date value.
VB Code:
lcsql = "Select * from TaxName Where Meeting_ID= " & _
Chr(39) & Trim(Str(iMeeting_ID)) & Chr(39) & _
" And Event_Date ='02/02/2004'"
'OR
lcsql = "Select * from TaxName Where Meeting_ID= " & _
Chr(39) & Trim(Str(iMeeting_ID)) & Chr(39) & _
" And Event_Date =#02/02/2004#"
oRecData.Open lcsql, oDataConn, adOpenKeyset, adLockOptimistic, adCmdText
If oRecData.BOF = False and oRecData.EOF = False Then
'Do record manipulation or ???
Else
MsgBox "No Records Returned!", vbOkOnly+vbInformation, App.ProductName
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|