MySQL

Moderators: Jonathan
Number of threads: 259
Number of posts: 514

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
this sql statement is killing me Posted by chillimouse on 20 Dec 2002 at 1:34 AM
ok here it is i am trying to insert all of the data from a form into a SQL server database.
i am using visual basic 6

here is the statement i am trying to do
cmdemployee.CommandText = "INSERT INTO employees ('fname,midname,lname,address,ssn,city,state,zip,extention,employeeid,
hphonearea,wphonearea,hphone,wphone,emailaddress,employmentstat,
ethnicity,sex,religion,hiredate,dateofbirth') Values ('" & strfname & ", " & strmidname & ", " & strlname & ", " & straddress & ", " & strssn & ", " & strcity & ", " & cbbstate & ", " & strzip & ", " & zipext & ", " & rstotal & ", " & strhphonearea & ", " & strwphonearea & ", " & strhphone & ", " & strwphone & ", " & email & ", " & stremploymentstat & ", " & strethnic & ", " & strsex & ", " & strrelig & ", " & strhiredate & ", " & birthdate & "')"

ok now i have tried this about a million ways and this is how i have it right now.
the error i am getting is
"invalid object name 'employees'"

now i have another part of the form that is pulling information from this database and same table so it isn't in the connection because i am using the same connection string.
also as you notice i have single quotes areound the columns and the values this is because when i apss a variable into the values column i have to use the syntax
commandname.commandtext = "Insert into tablename ('columns) VALUES ('" & variable1 & "')"
now if i have the single quote in just the values list visual basic thinks that i have one more variable than i have columns.

if anyone can help me with this one i would greatly appreciate it
please email me with your suggestions

palmer_75@hotmail.com


thanks again
michael


Report
Re: this sql statement is killing me Posted by owen1 on 14 Jan 2003 at 1:39 PM
why are there single quotes around the colmns in the insert statement?

INSERT INTO employees ('fname,midname,lname,address,ssn,city,state,zip,extention,employeeid,
hphonearea,wphonearea,hphone,wphone,emailaddress,employmentstat,
ethnicity,sex,religion,hiredate,dateofbirth') Values

there should be no single quotes in this part like this

INSERT INTO employees (fname,midname,lname,address,ssn,city,state,zip,extention,employeeid,
hphonearea,wphonearea,hphone,wphone,emailaddress,employmentstat,
ethnicity,sex,religion,hiredate,dateofbirth) Values


http://owensoft.20m.com
check out my current projects: http://www.owensoft.net




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.