|
pronub Newbie
Joined: 19 Dec 2006 Posts: 2
|
Posted: Tue Dec 19, 2006 8:51 am
COMADO/SQL Database Troubles... |
Ok, im using COMADO to connect to a MS SQL Express database using ODBC on windows xp SP2...
I'm using the following (and i've tried MANY variations of everything...) to retreive data from a database of items...
Quote: |
#VAR Conn %comcreate( "ADODB.connection")
#noop @Conn.Open( "mysql")
;
#var rs %comcreate("ADODB.recordset")
#noop @rs.open("select * from eqdb where name like '%stuff%'", @conn)
;
#say @rs.recordcount |
despite this returning multiple items, two, AND being able to use:
Quote: |
#while (!@rs.eof) {#say @rs.Fields(name ).Value
#noop @rs.movenext} |
to show individual items, the recordcount comes out as -1... Is it not correctly making a recordset?
Also, I need to know how to display individual parts of the data once it's in a record set...
Using zmud's database and syntax as an example, i could search for an item, then in way of formatting the text to make it look pretty i could go:
Quote: |
#echo Name:&name, Level:&level, Type:&type... etc |
So, to use what i know to try and explain, something like:
Quote: |
#echo Name:@rs.fields( "name"), Level:@rs.fields( "level"), Type:@rs.fields( "type")... etc |
I can show any ONE column, but not multiple together, and not really as freely as i need. I need it to be as free as the zmud syntax (as in i can call the value at will to use in if's and the like) so i can code a whole heap of checks in to not display blank fields and fields i dont want to show... Having a generic format is no good, you dont wanna see damage dice and average on armor do you?
Eventually i need to be able to count how many results are returned, if it's within a certain limit, display just the names of each item so you can refine your search, and if only one item is returned, display the data in a nice format as per above.
Thanks for any help |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Tue Dec 19, 2006 10:20 am Re: COMADO/SQL Database Troubles... |
pronub wrote: |
Ok, im using COMADO to connect to a MS SQL Express database using ODBC on windows xp SP2...
Quote: |
#VAR Conn %comcreate( "ADODB.connection")
#noop @Conn.Open( "mysql")
|
|
So which is it? MS SQL Express or mysql? |
|
|
|
Strakc Apprentice
Joined: 31 Jan 2006 Posts: 106 Location: Virginia Beach, Virginia
|
Posted: Tue Dec 19, 2006 10:24 am |
isn't MS SQL Express the same as mysql?
|
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Tue Dec 19, 2006 11:03 am |
I can't work out if you joking or not, so I'll just say "No"!
|
|
|
|
pronub Newbie
Joined: 19 Dec 2006 Posts: 2
|
Posted: Tue Dec 19, 2006 4:12 pm |
Um, i -did- mention i'm using ODBC... "mysql" is what i called my ODBC connection... perhaps an inappropriate name, but completely irrelevant...
|
|
|
|
Strakc Apprentice
Joined: 31 Jan 2006 Posts: 106 Location: Virginia Beach, Virginia
|
Posted: Tue Dec 19, 2006 6:55 pm |
And no I wasn't kidding, I dont really know why Mysql is or Sql beyond the point that they are databases?
|
|
|
|
Rainchild Wizard
Joined: 10 Oct 2000 Posts: 1551 Location: Australia
|
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Wed Dec 20, 2006 2:06 am |
Er, yes "Mysql" is a pretty misleading name, given that it is the name of the most commonly used database engine on the internet. That's why I was asking for clarification. And because I know that Mysql behaves differently to MS-SQL Server when it comes to 'rowcount'...
|
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Wed Dec 20, 2006 2:14 am |
One way of verifying whether it is a database or ADO (MDAC) problem, or whether the problem in CMUD, is to basically convert your zScript into some other language like ASP / VBScript / JScript and see if you get recordcount working there... Also, did you try it in zMUD?
|
|
|
|
Rainchild Wizard
Joined: 10 Oct 2000 Posts: 1551 Location: Australia
|
Posted: Wed Dec 20, 2006 5:12 am |
Also, rowcount is often not available/implemented for a lot of database types (something to do with cursors and fetch on demand stuff on the database server).
You should be able to do a select count(*) from table where <clause> to get the rowcount if it is vital, but the usual way to query a recordset is a while !eof / movenext type thing, you can always increment a variable inside the while loop to keep track of how many records were returned. |
|
|
|
|
|