Solved

HELP with SQL and Maskedit boxes

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

810 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