Solved

HELP with SQL and Maskedit boxes

Posted on 1998-06-28
4
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month5 days, 22 hours left to enroll

627 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