Solved

HELP with SQL and Maskedit boxes

Posted on 1998-06-28
4
151 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now