Solved

HELP with SQL and Maskedit boxes

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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