Solved

HELP with SQL and Maskedit boxes

Posted on 1998-06-28
4
156 Views
Last Modified: 2010-05-03
Using VB 5.0, I am having trouble with the Insert Into and Update statements when saving to the
database.  I am using the following syntax ...  INSERT INTO (field1, field2,...) VALUES ('" & textbox & "','" &
mskedbox1 & "'...) and I get the error :  "Syntax error in insert into statement".  The same happens with update.  I've
narrowed  the problem down to the maskedit boxes (the textboxes work fine alone).  Suggestions?

I get the correct value showing when debugging.  I have also tried transferring the value to a textbox and then using the textbox to save to the database with SQL....same error.

NB  I posted this quesiton before, but my email address was incorrect, so I didn't get the answers ... sorry.
0
Comment
Question by:tporter
  • 2
4 Comments
 
LVL 3

Expert Comment

by:AndreasSchindler
ID: 1464469
dim s1 as string
.
s1=mskedbox1.text
.

.INSERT INTO (field1, field2,...) VALUES ('" & textbox & "','" & 
s1 & "'...)


0
 

Author Comment

by:tporter
ID: 1464470
The problem, which was not solved by the email I received, was that my field name was "date" ... apparently a reserved word and seen by SQL as poor syntax.  The suggestion that I should assign the value to a variable did not, of course, work.  Thanks anyway.

0
 
LVL 4

Accepted Solution

by:
tomook earned 100 total points
ID: 1464471
If you are using a reserved word as a field name, you will have to use a "quoted identifier" it in the SQL, i.e.
INSERT INTO ("date") VALUES (...

This forces most major the DMBS' to interpret the quoted text as a field name. btw, in SQL Server, it also allows you to use spaces in field names. In Oracle, it allows creating tables with mixed case field names.
0
 

Author Comment

by:tporter
ID: 1464472
Excellent answer ... it would have saved hours of blood, sweat and tears a couple of days ago!  Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question