Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Bernier Mejorada
  Where is Bernier Mejorada?
 Tagum City
 Philippines
 Bernier Mejorada
 To: Derrick Bruce
  Where is Derrick Bruce?
 Charlestown
 Indiana - United States
 Derrick Bruce
Subject: RE: VFP-SQL Commands
Thread ID: 170911 Message ID: 170918 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Friday, May 2, 2008 3:43:59 AM         
   



> > 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?

ENTIRE THREAD

VFP-SQL Commands Posted by Bernier Mejorada @ 5/2/2008 2:55:30 AM
RE: VFP-SQL Commands Posted by Jun Tangunan @ 5/2/2008 3:08:09 AM
RE: VFP-SQL Commands Posted by Derrick Bruce @ 5/2/2008 3:27:50 AM
RE: VFP-SQL Commands Posted by Bernier Mejorada @ 5/2/2008 3:43:59 AM
RE: VFP-SQL Commands Posted by Derrick Bruce @ 5/2/2008 3:54:28 AM
RE: VFP-SQL Commands Posted by Bernier Mejorada @ 5/2/2008 6:34:02 AM
RE: VFP-SQL Commands Posted by Jun Tangunan @ 5/2/2008 6:40:42 AM
RE: VFP-SQL Commands Posted by Bernier Mejorada @ 5/2/2008 7:02:35 AM
RE: VFP-SQL Commands Posted by Andy Kramek @ 5/2/2008 12:51:58 PM
RE: VFP-SQL Commands Posted by tushar @ 5/2/2008 3:01:58 PM
RE: VFP-SQL Commands Posted by Andy Kramek @ 5/2/2008 9:38:17 PM
RE: VFP-SQL Commands Posted by Derrick Bruce @ 5/2/2008 3:29:25 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/2/2008 3:47:20 PM
RE: VFP-SQL Commands Posted by Derrick Bruce @ 5/2/2008 4:00:31 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/2/2008 5:55:17 PM
RE: VFP-SQL Commands Posted by Andy Kramek @ 5/2/2008 9:32:09 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/2/2008 10:30:43 PM
RE: VFP-SQL Commands Posted by Andy Kramek @ 5/2/2008 10:53:16 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/3/2008 12:09:07 AM
RE: VFP-SQL Commands Posted by Andy Kramek @ 5/3/2008 2:00:30 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/3/2008 4:46:04 PM
RE: VFP-SQL Commands Posted by Mike Yearwood @ 5/3/2008 2:07:45 AM
RE: VFP-SQL Commands Posted by Bernier Mejorada @ 5/2/2008 4:01:32 AM