borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Filter by month???)Next Topic (Find command?) New Topic New Poll Post Reply
AndreaVB Forum : Database : Select Statement (SQL Query) Solved Topic
Poster Message
Gary
Level: Sage

Registered: 27-11-2005
Posts: 50

icon Select Statement (SQL Query)

Hi guys,

I would like to select all the records from Session 1 to Session 3 for a particular student. My code is as below:

rs.Open "SELECT DISTINCT * FROM view_ModuleReg WHERE ((LastName) = '" & frmModuleReg_ReportMenu.cbStudentName.Text & "') AND ((SessionID) = '" & frmModuleReg_ReportMenu.cbSession_From.Text & "') AND ((SessionID) = '" & frmModuleReg_ReportMenu.cbSession_To.Text & "')", conn, adOpenStatic, adLockOptimistic
        
Set drpt_StudentName_SessionN_ModuleReg.DataSource = rs

It seems like it is not working.. Any idea on this?

Thank you


Gary

07-12-2006 at 08:11 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Select Statement (SQL Query)

it will always return an empty recordset because you are using = with two different session IDs. try this

rs.Open "SELECT DISTINCT * FROM view_ModuleReg WHERE ((LastName) = '" & frmModuleReg_ReportMenu.cbStudentName.Text & "') AND ((SessionID) >= '" & frmModuleReg_ReportMenu.cbSession_From.Text & "') AND ((SessionID) <= '" & frmModuleReg_ReportMenu.cbSession_To.Text & "')", conn, adOpenStatic, adLockOptimistic

you can also use the BETWEEN statement just like:
...WHERE SessionID BETWEEN 1 AND 3

____________________________
AndreaVB

07-12-2006 at 10:00 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Gary
Level: Sage

Registered: 27-11-2005
Posts: 50
icon Re: Select Statement (SQL Query)

Hi Admin,

Thanks for your advice, it works successfully...


Gary

08-12-2006 at 10:26 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Select Statement (SQL Query) Solved Topic
Previous Topic (Filter by month???)Next Topic (Find command?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder