|
-
Feb 19th, 2005, 08:16 AM
#1
Thread Starter
Fanatic Member
SQL statement
Hi All,
What is wrong with this SQL statment, as VB does not like it
VB Code:
rst.Open "SELECT Controller.FirstName, Controller.Lastname, Controller.Time, Controller.Teachers_Name From Controller=WHERE (((Controller.Time)="17:00") AND ((Controller.Teachers_Name)="Lauren ellis"))", Adodc1.ConnectionString, adOpenKeyset, adLockOptimistic
Thnaks
Loftty
-
Feb 19th, 2005, 09:26 AM
#2
Re: SQL statement
TIME is a reserved word - you should avoid field names with reserved words.
See the link in my signature for a list of other reserved words.
You can overcome the problem by wrapping the column name in []-brackets, but that doesn't always work (bugs in some tools make the field simply not accessible).
-
Feb 19th, 2005, 01:17 PM
#3
Thread Starter
Fanatic Member
Re: SQL statement
Hi,
I have changed the time to Time_Lesson
but I get an error saying expected end of statement and points to 17
VB Code:
rst.Open "SELECT Controller.FirstName, Controller.Lastname, Controller.Time_Lesson, Controller.Teachers_Name From Controller WHERE (((Controller.Time_Lesson)="17:30")" AND ((Controller.Teachers_Name)="ben riches"))", Adodc1.ConnectionString, adOpenKeyset, adLockOptimistic
What am I doing wrong here?
Thanks
Loftty
-
Feb 19th, 2005, 01:22 PM
#4
Re: SQL statement
Use single quotes to delimit the values within the string and double quotes to delimit the entire string
VB Code:
WHERE (((Controller.Time_Lesson)="17:30")" AND ((Controller.Teachers_Name)="ben riches"))", adodc
should be
WHERE (((Controller.Time_Lesson)='17:30') AND ((Controller.Teachers_Name)='ben riches'))", adodc
-
Feb 19th, 2005, 01:30 PM
#5
Re: SQL statement
 Originally Posted by brucevde
Use single quotes to delimit the values within the string and double quotes to delimit the entire string
VB Code:
WHERE (((Controller.Time_Lesson)="17:30")" AND ((Controller.Teachers_Name)="ben riches"))", adodc
should be
WHERE (((Controller.Time_Lesson)='17:30') AND ((Controller.Teachers_Name)='ben riches'))", adodc
I didn't even scroll that far over!
-
Feb 19th, 2005, 02:02 PM
#6
Thread Starter
Fanatic Member
Re: SQL statement
Hi,
Done what you said by using singe quotes, thankyou, how can I see the output that I get?
Thanks
Loftty
-
Feb 19th, 2005, 02:26 PM
#7
Re: SQL statement
The RST object has property and methods - look up help file on RECORDSET object...
Here a really simply snippet - there is more to this (moving to next record - stuff like that).
Code:
rs.Open "SELECT dbo.GetConf('" & ConfItem _
& "') as ConfData", gCn
GetConf = rs!ConfData & ""
rs.Close
Set rs = Nothing
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
|