#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default SQL syntax


Im having trouble writing a dynamic SQL statement and was hoping someon
knew where I could get some help on how Excel breaks up the string.

.CommandText = Array( _
"SELECT COUNT(*)" & Chr(13) & "" & Chr(10) & _
"FROM `P:\Capacity Planning`.InternalBORIssue
InternalBORIssues" & Chr(13) & "" & Chr(10) & _
"WHERE (InternalBORIssues.Date={ts '2005-06-10 00:00:00'}) AN
(InternalBORIssues.intext=)" & mine & _
)
I keep getting seperator expected or end of line expectd also the las
where statement doesnt seem to work either, how do I use variables?
Thanks in advance
Jef

--
Jeffie
-----------------------------------------------------------------------
Jeffiec's Profile: http://www.excelforum.com/member.php...fo&userid=2429
View this thread: http://www.excelforum.com/showthread.php?threadid=37900

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default SQL syntax

Implementations of SQL vary by the source database, but generally you do not
need the Array() nor the Chr(13) & Chr(10); the biggest trick is to handle
any text criteria or parameters properly by inserting (normally) single
quotes; so try this:

..CommandText = "SELECT COUNT(*) FROM 'P:\Capacity Planning'.InternalBORIssues
InternalBORIssues WHERE (InternalBORIssues.Date={ts '2005-06-10 00:00:00'})
AND (InternalBORIssues.intext='" & mine & "')

around & mine & please note the single quotes around the double quotes.

"Jeffiec" wrote:


Im having trouble writing a dynamic SQL statement and was hoping someone
knew where I could get some help on how Excel breaks up the string.

.CommandText = Array( _
"SELECT COUNT(*)" & Chr(13) & "" & Chr(10) & _
"FROM `P:\Capacity Planning`.InternalBORIssues
InternalBORIssues" & Chr(13) & "" & Chr(10) & _
"WHERE (InternalBORIssues.Date={ts '2005-06-10 00:00:00'}) AND
(InternalBORIssues.intext=)" & mine & _
)
I keep getting seperator expected or end of line expectd also the last
where statement doesnt seem to work either, how do I use variables?
Thanks in advance
Jeff


--
Jeffiec
------------------------------------------------------------------------
Jeffiec's Profile: http://www.excelforum.com/member.php...o&userid=24296
View this thread: http://www.excelforum.com/showthread...hreadid=379009


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA syntax dhstein Excel Discussion (Misc queries) 3 March 13th 09 12:53 PM
VB Syntax dhstein Excel Discussion (Misc queries) 6 November 8th 08 09:13 PM
VBA syntax Sunantoro Excel Discussion (Misc queries) 1 September 21st 05 03:19 AM
Syntax James Bronsan Excel Programming 1 August 12th 04 09:09 PM
Need some syntax help, please MARTY Excel Programming 3 July 4th 04 04:36 PM


All times are GMT +1. The time now is 08:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"