mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2003
Posts: 9
N
NMB Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Mar 2003
Posts: 9
ok check this out...
alias testdb {
comopen test Adodb.Connection
echo -s provider: $com(test,Provider,4,bstr,Microsoft.Jet.OLEDB.4.0)
echo -s connstring: $com(test,ConnectionString,4,bstr,test.mdb)
echo -s open $com(test,Open,3)
echo -s SQL: $com(test,execute,4,bstr,insert into silikon (nick) values ('write this'))
comclose test
}

this snippet will type "write this" to the position nick in the table silikon in the databas test.mdb...

this works 100% as i want it... but i want to read from this databas to... soo...

alias testdb2 {
comopen test Adodb.Connection
echo -s provider: $com(test,Provider,4,bstr,Microsoft.Jet.OLEDB.4.0)
echo -s connstring: $com(test,ConnectionString,4,bstr,test.mdb)
echo -s open $com(test,Open,3)
echo -s SQL: $com(test,execute,4,bstr,select nick from silikon order by id)
comclose test
}


ok... im not realy into normal coding and such... but in "basic code languages (VB & ASP and so on)" the thing i want would look like this "set recset = test.execute("select nick from silikon order by id")" but in mirc i don't closer to this then "$com(test,execute,4,bstr,select nick from silikon order by id)" if i would proceed with basic code to get the info then i would have use "recset("nick")" to get a value from the nick place in the silikon table.


i read about dispatch and unknown in the mirc help and noticed pointers... but i didn't realy understand it... is that maybe what i need to learn to get this to work?


anyhow... please help me... i've looked everyplace i know to look at...
THANKS ON FOREHAND

-----this post is belong l337 ----

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Sorry, I have no idea how to make mirc do that. The part of the help file regarding unknown/dispatch pointers is very unclear. If Khaled reads it, I'd be thankful if he shows up and gives an example.

Joined: Dec 2002
Posts: 86
D
Babel fish
Offline
Babel fish
D
Joined: Dec 2002
Posts: 86
I don't think that this is currently possible with mIRC's COM support.

You can work around it easily by writing your own COM dll in VB and using that to make easy methods for dealing with ADO recordsets.

-chris

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
According to the help file it should be possible,

     "To retrieve a dispatch/unknown pointer through a call to $com(), specify the variable type as dispatch/unknown with *, and assign it a variable name. When $com() returns, mIRC will create a new $com() item with that variable name and assign it the dispatch or unknown pointer."

yet nobody knows how to implement this into a $com() call...

Joined: Dec 2002
Posts: 86
D
Babel fish
Offline
Babel fish
D
Joined: Dec 2002
Posts: 86
There's no way to set a dispatch pointer if the method called returns the pointer. If it has a byref argument, then its easy to do with dispatch *.

With ADO, you'd need to be able to catch the returned dispatch pointers. I think this is just a common problem with procedural vs OO languages. mIRC is the former, COM represents the latter in most cases.

I've written a quick COM ADO wrapper that just exposes enough of the ADO API to do simple SQL commands and get data back. I'll post the code/dll sometime soon.

-chris

Joined: May 2003
Posts: 9
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: May 2003
Posts: 9
You could use the Recordset directly. You don't always need to have a connection object.

So the VB code would like something like the following

Dim oRS As ADODB.Recordset
Set oRS = New ADODB.Recordset
oRS.ActiveConnection = "provider"
oRS.Open "select * from xyz"

Now to get the data you can't use the Fields object according to the other replies. If your trying to get a really simple value you could use the GetString method.

GetString will also return a deliminated list of items which you could then parse and do whatever.

Of course the easiest solution is writting your own wrapper for ADO.

Joined: Mar 2003
Posts: 9
N
NMB Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Mar 2003
Posts: 9
Thanks , your solution is so good~~~.

Joined: Mar 2003
Posts: 9
N
NMB Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Mar 2003
Posts: 9
BUT,i still can not read oRS("nick").
$com can't return string

Joined: May 2003
Posts: 9
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: May 2003
Posts: 9
$COM can return a string.

Problem is your not accessing a method. You need to get access to the Field object in order to get the value out. You could try the GetString approach.

When you use that syntax your accessing a default method which I belive is the Collect method. This returns a field object which has the default method set as Value. So this will not work for the same reasons the other ones won't.

Hope this helped.


Link Copied to Clipboard