473,473 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Constructing Strings in Visual Basic

44 New Member
Hi all,

I need to run a SQL statement in Microsoft VB.

The following statement returns an error "Compile Error: Expected: end of statement". yyyy was highlighted when the error was encountered.

I believe that there are something wrong with my syntax. It could be the quotes (") that I have used to enclose the date format.

I would appreciate if anyone could help to correct.

************************************************

strSQL = "SELECT DISTINCT Min(Format([SHOW_DATE],"yyyy/mm/dd")) AS [Start Date], Max(Format([SHOW_DATE],"yyyy/mm/dd")) AS [End Date] INTO NewSurveys" _
& "From STIXMV_EVENT_SHOW HAVING (((Max(Format([SHOW_DATE],"yyyy/mm/dd")))=Format(Date()-15,"yyyy/mm/dd")));"
************************************************

Regards,
Clarence
Oct 28 '08 #1
2 1543
MikeTheBike
639 Recognized Expert Contributor
Hi all,

I need to run a SQL statement in Microsoft VB.

The following statement returns an error "Compile Error: Expected: end of statement". yyyy was highlighted when the error was encountered.

I believe that there are something wrong with my syntax. It could be the quotes (") that I have used to enclose the date format.

I would appreciate if anyone could help to correct.

************************************************

strSQL = "SELECT DISTINCT Min(Format([SHOW_DATE],"yyyy/mm/dd")) AS [Start Date], Max(Format([SHOW_DATE],"yyyy/mm/dd")) AS [End Date] INTO NewSurveys" _
& "From STIXMV_EVENT_SHOW HAVING (((Max(Format([SHOW_DATE],"yyyy/mm/dd")))=Format(Date()-15,"yyyy/mm/dd")));"
************************************************

Regards,
Clarence
Hi

You need to duplicate all the quotation marks that are part of the string (those that do not start or end the string) like this

strSQL = "SELECT DISTINCT Min(Format([SHOW_DATE],""yyyy/mm/dd"")) AS [Start Date], Max(Format([SHOW_DATE],""yyyy/mm/dd"")) AS [End Date] INTO NewSurveys " _
& "From STIXMV_EVENT_SHOW HAVING (((Max(Format([SHOW_DATE],""yyyy/mm/dd"")))=Format(Date()-15,""yyyy/mm/dd"")));"

By doing this the complier/interpreter/parser know when you want a quotation mark in the string and where the string starts and stops!


HTH


MTB
Oct 28 '08 #2
clarencelai
44 New Member
Hi..

Thanks for your help!

Regards,
Clarence


Hi

You need to duplicate all the quotation marks that are part of the string (those that do not start or end the string) like this

strSQL = "SELECT DISTINCT Min(Format([SHOW_DATE],""yyyy/mm/dd"")) AS [Start Date], Max(Format([SHOW_DATE],""yyyy/mm/dd"")) AS [End Date] INTO NewSurveys " _
& "From STIXMV_EVENT_SHOW HAVING (((Max(Format([SHOW_DATE],""yyyy/mm/dd"")))=Format(Date()-15,""yyyy/mm/dd"")));"

By doing this the complier/interpreter/parser know when you want a quotation mark in the string and where the string starts and stops!


HTH


MTB
Nov 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: pix | last post by:
Hello, I would like to start learning Visual Basic, and I was wondering if there are any recomendations to any ebooks, or actual books for that matter. I have my eye on this book by John Smiley,...
4
by: LCAdeveloper | last post by:
I have had to move to Visual Studio.NET Pro. from Visual Basic 4.0 and am now starting to re-write our code. I was a bit surprised to find that Visual Basic.NET no longer supports fixed length...
10
by: Aris | last post by:
A few days ago I asked from you how to join a string like "file" A number that change values from 1 to 5 and another string like ".txt" to have a result like "file1.txt","file2.txt" and so on ...
11
by: bgreen | last post by:
I am hoping for some assistance with formatting a large text file which consists of a series of individual records. Each record includes specific labels/field names (a sample of 1 record (one of...
9
by: Daniel N | last post by:
hWnd = FindWindow("CLASS NAME", *) A string must be where the (*) is. Is there a way of making some kind of wildcard so that function accepts every string sting?
3
by: James | last post by:
What's the difference between += and &= with reference to strings? Also, what are string literals? Thanks. And what are fixed lenth strings? and how do you declare them? Thanks
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
5
by: kylemort | last post by:
I am currently using a class (Card) to represent a card in a deck of cards. The class has a constructor: Card::Card(int num, int su) { suit = su; number = num; } and I am trying to create...
10
by: =?Utf-8?B?RGFyYSBQ?= | last post by:
Can some one suggest me as why StringBuilder class is better than Strings? -- Never say, Give up
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.