Sign in to follow this  
Followers 0
oshaker

Only Object-type variables allowed in a "With" statement.

11 posts in this topic

#include "mysql.au3"

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

Dim $var, $sql

$sql = _MySQLConnect("UserName","Password","DB_Name","DB_IP_Address")
$var = _Query($sql,"SELECT user.user_id, user.firstname,user.username,course.code FROM dokeos_main.user ,dokeos_main.course_rel_user, dokeos_main.course where user.user_id=course_rel_user.user_id and course_rel_user.course_code=course.code" )

FileOpen ( "c:\test.txt", 130)

With $var
While NOT .EOF
FileWriteLine("c:\test.txt",.Fields("username").value & "," & .Fields("firstname").value & .Fields("code").value & @CRLF)
.MoveNext
WEnd
EndWith
_MySQLEnd($sql)


Func MyErrFunc()

$hexnum=hex($objErr.number,8)

Msgbox(0,"","We intercepted a COM Error!!"        & @CRLF                   & @CRLF & _
             "err.description is: "    & $objErr.description    & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & $objErr.scriptline     & @CRLF & _
             "err.number is: "         & $hexnum                 & @CRLF & _
             "err.source is: "         & $objErr.source         & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile       & @CRLF & _
             "err.helpcontext is: "    & $objErr.helpcontext _
            )
exit
EndFunc

This gives me:

Only Object-type variables allowed in a "With" statement.

With $var

With ^ ERROR

How can I fix it?

Share this post


Link to post
Share on other sites



From memory that function returns an array. So For...Next will do the job. See what the function returns first though. Should be some documentation in MySQL.au3.

Cheers,

Brett

Share this post


Link to post
Share on other sites

re-installing the ODBC MySQL driver solved the problem.

Share this post


Link to post
Share on other sites

Hello. Im getting the same error with my script.

Well, the scripts works fine in my PC but im getting this error on another computer...

Regards

Centinelav2.exe

Centinelav2.au3

Share this post


Link to post
Share on other sites

I introduced the code from ptrex

http://www.autoitscript.com/forum/index.php?showtopic=111169&view=findpost&p=781749

And the result was this:

Posted Image

Share this post


Link to post
Share on other sites

I am unable to replicate but some observations. You called ObjCreate like 10 times in the one function. There was no need for it and I opened the object at the start of the script. Other than that there were no real problems I could see (or test).

Please grab the full version of SciTE and run it from there. Past the console output, so at least we know where the error is coming from.

Cheers,

Brett

Share this post


Link to post
Share on other sites

error is get by $com. In code line "With $com"

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Which one? There are 4 different occurrences of it? What does that error mean in ENGLISH? Have you Googled the error and the error code?

Edited by BrettF

Share this post


Link to post
Share on other sites

The error is that the "MSCommLib.MSComm" object is not being created.

If this is working on your PC but not on anther PC then I would suspect that the PC on which it is not working does not have "MSCommLib.MSComm" installed. I don't believe that MScomm is a standard component of windows. check if this file exists on the PC with the problem "C:\WINDOWS\system32\MSCOMM32.OCX".


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

It happenes to me as well but on random computers in our company. Just now one computer was failing to connect on line

$Objconn.open in _MySQLConnect function

and that Comerror handler failed to catch it although it works in other cases! Is it because I compiled it with Autoit 3.3.0.0? Unfortunatelly I restarted the computer and then it works again without error! So I will have to wait when it happens next time :-\

Edited by LoWang

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0