mIRC Home    About    Download    Register    News    Help

Topic Options
#23751 - 12/05/03 03:51 AM Using COM to access an Microsoft Access Database
NMB Offline
Nutrimatic drinks dispenser

Registered: 12/03/03
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 ----

Top
#23752 - 12/05/03 05:35 AM Re: Using COM to access an Microsoft Access Database
Online Offline
Hoopy frood

Registered: 09/12/02
Posts: 1922
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.

Top
#23753 - 12/05/03 02:40 PM Re: Using COM to access an Microsoft Access Database
d00dman Offline
Babel fish

Registered: 07/12/02
Posts: 86
Loc: Iowa, USA
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

Top
#23754 - 13/05/03 01:48 AM Re: Using COM to access an Microsoft Access Database
Online Offline
Hoopy frood

Registered: 09/12/02
Posts: 1922
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...

Top
#23755 - 15/05/03 04:44 PM Re: Using COM to access an Microsoft Access Database
d00dman Offline
Babel fish

Registered: 07/12/02
Posts: 86
Loc: Iowa, USA
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

Top
#23756 - 18/05/03 11:32 PM Re: Using COM to access an Microsoft Access Database
jberke Offline
Nutrimatic drinks dispenser

Registered: 18/05/03
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.

Top
#23757 - 19/05/03 09:03 AM Re: Using COM to access an Microsoft Access Database
NMB Offline
Nutrimatic drinks dispenser

Registered: 12/03/03
Posts: 9
Thanks , your solution is so good~~~.

Top
#23758 - 21/05/03 03:24 PM Re: Using COM to access an Microsoft Access Database
NMB Offline
Nutrimatic drinks dispenser

Registered: 12/03/03
Posts: 9
BUT,i still can not read oRS("nick").
$com can't return string

Top
#23759 - 27/05/03 10:19 PM Re: Using COM to access an Microsoft Access Database
jberke Offline
Nutrimatic drinks dispenser

Registered: 18/05/03
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.

Top