#134335 - 2005-02-24 12:10 AM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
Just your code by itself get the result of:
"Operation completed succesfully"
But when I put my code back in I still get the error message from before.??
|
Top
|
|
|
|
#134337 - 2005-02-24 12:19 AM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
I have put the following:
Code:
$ConnDSN = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=ncives;USER=test;PASSWORD=test;OPTION=3;"
$sql = 'SELECT * FROM workst' ? $sql sleep 3
$recordset = DBCommand($ConnDSN,$sql)
$connection = createobject("adodb.connection") ?$recordset
$= $connection.open($ConnDSN)
? @SERROR
? 'Error = '+@ERROR+' - '+@SERROR sleep 1
for $row=0 to ubound($recordset,1) for $column=0 to ubound($recordset,2) ? 'Field(row='+$row+', column='+$column+') ='+$recordset[$row,$column] next next
? "Your workstation ID number is " + $Recordset
And it appears to NOT be erroring out. It says completed sucessfully in two places. ... but never shows any data. I'm confused!
|
Top
|
|
|
|
#134339 - 2005-02-24 12:26 AM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
Now I get this error:
Script Error: IDispatch pointers not allowed in exrpession.
|
Top
|
|
|
|
#134341 - 2005-02-24 12:46 AM
Re: ODBC - DBcommand
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
You cannot just print out an array as in Code:
? $Recordset
Alos, why do you create a separate recordset? Try this: Code:
$ConnDSN = 'DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=ncives;USER=test;PASSWORD=test;OPTION=3;'
$sql = 'SELECT * FROM workst' ? 'SQL = '+$sql
$recordset = DBCommand($ConnDSN,$sql) ? 'Error '+@ERROR+' - '+@SERROR
for $row=0 to ubound($recordset,1) for $column=0 to ubound($recordset,2) ? 'Field(row='+$row+', column='+$column+') ='+$recordset[$row,$column] next next
Finally, sprinkle the UDF itself with error checks and step through it via DEBUG ON to see why it fails.
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#134342 - 2005-02-24 06:58 PM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
Sealepoard ....
Running Through DEBUG ON .... the error shows up when it gets to this:
? 'Error '+@ERROR+' - '+@SERROR
And It is still the same error:
Error = 2147352567 COM exception error "Open" (ADODB.Recordset - The connection cannot be used to perform this operation. It is either closed or invalid in this context.) [-2147352567/80020009]
|
Top
|
|
|
|
#134343 - 2005-02-24 07:11 PM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
Shawn,
When I remove all of my code out and replace it with just the code you have shown ... it says Operation complete twice .... and then ... Press any key to conitue.
But still doesn't show any data.
Any other ideas??
|
Top
|
|
|
|
#134344 - 2005-02-24 07:37 PM
Re: ODBC - DBcommand
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
ok, then lets just see if we can get the results of your query ... heres some new code, change the details as required ... then in the rs.EOF loop, try to display-out one of your field names ... this line here:
?"Name=" $rs.Fields("Name").Value
Change it to display one of your fields. Its good to dig down to this level because it gives an appreciation for how this stuff works under-the-covers (imho) ...
Code:
break on
$= SetOption("WrapAtEol", "On")
$connection = createobject("adodb.connection")
$ConnDSN = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=phone;USER=root;PASSWORD=******;";OPTION=3;"
$= $connection.open($connDSN)
$rs = $connection.execute("SELECT Name FROM Business WHERE Name = 'Shawn'")
While Not $rs.EOF
?"Name=" $rs.Fields("Name").Value
$rs.MoveNext
Loop
exit 1
If you dont see any values, try putting in an @ERROR to catch the error. If it does, we can move on ...
|
Top
|
|
|
|
#134345 - 2005-02-24 07:52 PM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
Boo ya! I got results!!
Cool .... I just added back in the rest of my code and it works fine ... So why did the UDF not work?? Is it buggy?
Thanks so much for your help!!!
Faithful
|
Top
|
|
|
|
#134347 - 2005-02-24 08:10 PM
Re: ODBC - DBcommand
|
Faithfulman
Getting the hang of it
Registered: 2005-02-22
Posts: 68
|
I think that the code you showed will be fine as is. Thanks again so much.
Faithful
|
Top
|
|
|
|
#134349 - 2005-02-25 04:32 AM
Re: ODBC - DBcommand
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Jens, thought I could help-out by doing a bit of debugging with my mysql, but this syntax works perfectly for me:
Code:
break on
$dsn = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=phone;USER=root;PASSWORD=******;option=3"
$sql = "SELECT Name FROM Business WHERE Name = 'Shawn'"
$rows = DBCommand($dsn, $sql)
? @SERROR
?"VarTypeName=" VarTypeName($rows)
exit 0
Get this:
Quote:
E:\>kix32 t
The operation completed successfully.
VarTypeName=Variant[]
So, this might be some kind of weird issue with his instance.
-Shawn
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 366 anonymous users online.
|
|
|