this sql statement is killing me - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

this sql statement is killing me

chillimousechillimouse Posts: 59Member
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

[email protected]


thanks again
michael


Comments

  • owen1owen1 Posts: 76Member
    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
    [hr]
    http://owensoft.20m.com
    check out my current projects: http://www.owensoft.net

Sign In or Register to comment.