Accessing mysql using mIRCs COM features - 04/02/05 06:44 PM
I took this from a post made by Hammer.
note: I changed a few things around but I tried the example shown in Hammers post, even created the table, installed the driver, etc and still got an error.
-
* Invalid parameters: $com (line 60, mysqldb.mrc)
-
Line 60:
%SQL:
Whenever typing the alias, the MySQL Name Data Source dialog appears.
Any ideas why this is encountering an error?
When issuing the /mysql.getnickdata
Code:
alias mysql.GetNickData { ; Open an ADODB Connection object. ; .comopen mysql.Database ADODB.Connection ; For the purposes of this example, I have shortened the Open method declaration by defining a variable ; to hold a proper mysql connection string. Again, if this step does not work for you, then you will need ; to install the OLEDB driver from here (picking the closest mirror). ; var %Connection.String = Provider=MySQLProv;Data Source=mIRC;User ID=root;Password=<edited> ; Open the connection to the mysql database you wish to work with, specified in the Data Source ; parameter above. ; .echo -q $com(mysql.Database, Open, 1, *bstr, %Connection.String) ; Open an ADODB Recordset object. ; .comopen RecordsetObject ADODB.Recordset ; Again, to shorten the Open method line, I have put the SQL I want to use to populate the recordset ; inside a variable. ; var %SQL = SELECT * FROM mp3s; ; Open the recordset object using the previously setup SQL variable on the Connection object. ; .echo -q $com(RecordsetObject, Open, 1, *bstr, %SQL, dispatch, mysql.Database, int, 1, int, 3, int 1) ; The Collect property is an undocumented shortcut way to grab just the value held in the fields ; which are zero-based. As you can see from the SQL above, I have specified 3 fields I wish returned: ; ; * FirstName (field 0) ; * LastName (field 1) ; * Gender (field 2) ; ; So, I grab the data from the FirstName field and store the result in the variable %Name. ; .echo -q $com(RecordsetObject, Collect, 2, i4, 0) var %Name = $com(RecordsetObject).result ; Then I grab the data from the LastName field and add it to the %Name variable. ; .echo -q $com(RecordsetObject, Collect, 2, i4, 1) var %Name = %Name $com(RecordsetObject).result ; Then I grab the Gender data and put it in its own variable, surrounded by parentheses. ; .echo -q $com(RecordsetObject, Collect, 2, i4, 2) var %Gender = ( $+ $com(RecordsetObject).result $+ ) ; Now I can return or display the results from the database query to the active window. ; if ($isid) return %Name %Gender else echo -gaitc info * $1 is %Name %Gender ; And finally, (being the neat little programmer that I am) I close the two objects I have used. ; .comclose RecordsetObject .comclose mysql.Database }
note: I changed a few things around but I tried the example shown in Hammers post, even created the table, installed the driver, etc and still got an error.
-
* Invalid parameters: $com (line 60, mysqldb.mrc)
-
Line 60:
Code:
.echo -q $com(RecordsetObject, Open, 1, *bstr, %SQL, dispatch, mysql.Database, int, 1, int, 3, int 1)
%SQL:
Code:
var %SQL = SELECT * FROM mp3s;
Whenever typing the alias, the MySQL Name Data Source dialog appears.
Any ideas why this is encountering an error?
When issuing the /mysql.getnickdata