Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A strange problem about my sql pass through statements!
Message
 
À
03/12/1997 22:27:20
Ron Tse-Jung Huang
Leader Professional Consulting
Shin-Chu, Taiwan
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00063586
Message ID:
00063746
Vues:
57
>>>Dear all,
>>>
>>>I am just beginning to start writing codes for C/S trials. One very strange problem which occurs very often is the execution of spt statements. Sometimes a spt executes successfully, and positive number is returned, while, the same form, same spt fails at other times. I don't know what causes the problem. Can someone suggest where I should look into?
>>>
>>>Many thanks.
>>>
>>>Best regards,
>>>Ron.
>>
>>
>>Can you post an example of your code? It's hard to answer these kind of questions without seeing what it is you are doing!
>
>Following are two pieces of codes that sometimes execute well, but sometimes fail. Here I mean the same piece of code behaves differently at different points of time.
>
>===
>Code 1:
>
>if thisform.c2.value=1
> result2=sqlexec(gldb,"exec dobonus ?thisform.text1.value, ?thisform.text2.value")
> if result2<1
> =messagebox("¥¼¦¨¥\°õ¦æ¸ê®Æ®w¤º³¡¹Bºâ, ¦A¸Õ¤@¹M",0,"¥¼°õ¦æ¦¨¥\")
> endif
>endif
>
>===
>Code 2:
>thisform.r2grid1.recordsource=""
>result=sqlexec(gldb,"select saleitem.*,person.p_nam from saleitem,person where saleitem.year=?yy and saleitem.month=?mm and mem_id=p_nid","sale1")
>if result<0
> ??chr(7)
> =messagebox("SQLEXEC()³]©w¿ù»~!")
> return
>endif
>
>thisform.r2grid1.recordsource="sale1"
>thisform.r2grid1.column1.controlsource="sale1.mem_id"
>thisform.r2grid1.column2.controlsource="sale1.p_nam"
>thisform.r2grid1.column3.controlsource="sale1.pv"
>thisform.r2grid1.column4.controlsource="sale1.gv"
>thisform.r2grid1.column6.controlsource="sale1.ov"
>
>thisform.r2grid1.refresh()
>
>
>Both of these codes are in the same project which has set up a connection to the backend database at the start with the following code:
>SET DEFAULT TO c:\Gl
>SET PATH TO PROGS, Forms, LIBS, ;
> MENUS, OTHER, ;
> REPORTS, INCLUDE, HELP, ;
> BITMAPS
>
>Deactivate Window "Microsoft Visual Foxpro"
>_SCREEN.WindowState = 2
>
>MODIFY WINDOW SCREEN;
> TITLE "¸¯¶©¤H¨Æ¼úª÷ºÞ²z¨t²Î"
>SET SYSMENU OFF
>public gldb
>gldb=sqlconnect("gldata","sa","")
>if gldb<1
> =messagebox("©M«áºÝ¸ê®Æ®w³s½u¥¢±Ñ,½Ð½T»{¦U¶µ³]©w",1,"³s½u¥¢±Ñ")
> quit
>endif
>DO FORM Login
>READ EVENT
>
>
>
>Sincerely, I still don't have clear ideas about synchronous and batched. I am sure that is what I should make effort.
>But the mode used here is what provided without any change.
>
>I will appreciate your time. MANY Thanks!

Since you don't seem to be running your pass-through synchronously (this is set with SQLSETPROP()), the only values SQLEXEC should return are 1 and -1. A return value of -1 is a connection level error, meaning something went wrong on the SQLServer side. Use AERROR() to get the error message SQLServer sent back. The error message is in the second column of the array row. Output the message in your MESSAGEBOX(). Be aware that sometimes SQLServer will return more than one error message, so check all the rows in your AERROR array.

On another subject, I couldn't help but notice that your 'sa' userid in SQLServer still has the default blank password that's assigned on installation. You should change that immediately! Anyone who knows anything about SQLServer knows about 'sa' and blank passwords. A definite security risk! Just my two cents.
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform