> > Hi Bernier,
> >
> > I advise you to surrond your commands with code block tags for readability purposes, in the future. You can do that by putting < vfp > in the beginning and ending it with < /vfp > (without the spaces) or you can highlight your commands then click the code block tag icon above.
> >
> > Otherwise, you will get the result like in your post.
> >
> > For now, I will fix it for you here. Notice the difference.
> >
> > Jun
> >
> >
"It doesn't matter how many times you fell in your life, what counts is how many times you stood up after that."> >
> >
> > *****
> >
> >
> >
> >
> > Dear VFP Experts,
> >
> > Good Day!
> >
> > Please, I need assistance. What's wrong with my VFP-SQL commands? It will not insert record in the SQL database.
> >
> >
> > mhandle = SQLCONNECT("MS-SQL","buenas","buenas")
> > IF mhandle > 0
> > MESSAGEBOX('SQL CONNECTION ESTABLISHED!',64,'Connect')
> > SQLEXEC(mhandle,'USE IMS')
> > SQLEXEC(mhandle, 'DELETE FROM Item')
> > SELECT * FROM STOCKINV!Stock WHERE Stock.fretcost > 0 AND ;
> > LEN(ALLTRIM(fprodcode)) <= 13 INTO CURSOR Crmitem
> > IF !EOF()
> > SCAN
> > mprodcode = REPLICATE('0',13-LEN(ALLTRIM(fprodcode)))+ALLTRIM(fprodcode)
> > mlongdesc = flongdesc
> > mshortdesc = fshortdesc
> > mrunit = frunit
> > mretcost = fretcost
> > SQLEXEC(mhandle,'INSERT INTO Item(barcode,itemname,shortname,uom,amt) ;
> > VALUES(mprodcode,mlongdesc,mshortdesc,mrunit,mretcost)')
> > ENDSCAN
> > ENDIF
> > SQLEXEC(mhandle, 'SELECT * FROM Item')
> > SQLDISCONNECT(mhandle)
> > ELSE
> > MESSAGEBOX('SQL CONNECTION FAILED!',64,'Error')
> > ENDIF
> >
>
> Just a quick stab at something I see.
>
> The only way I've managed to feed variables into SQL using SQLEXEC is by using ?m. in front of the variable name. So ?m.mprodcode, etc.
>
> Couple other checks - do you have insert and delete access to the table or read only?
>
> But a Cursor and array on your last sqlexec and see what it reports back.
>
> D
Does it matter using "m." or without "m." in a memory variable?
I have INSERT and DELETE access of the table. The SQLEXEC(mhandle, 'DELETE FROM Item') is functioning well, only the SQLEXEC(INSERT...) didn't work. Is there something wrong with my command?