|
|||
|
I'm working on this ADO example in this thread:
http://www.swfkit.com/forum/thread_1_489.html And our Administrator show us an excellent example on how to use ADO directly in actionscript. Quote:
I can't find these in the help file of SWFKit 3.1 |
|
|||
|
ADO Reference
http://msdn.microsoft.com/library/de...dooverview.asp ADO Tutorial http://www.w3schools.com/ado/default.asp |
|
|||
|
Thanks for your response!
But I think it seems to be different between asp+ado and swfkit+ado For example: Code:
import SWFKit.*;
import ADODB.*;
var ax = new ActiveXObject("ADODB.Connection");
var conn = new _Connection(ax.Identifier);
var connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Global.getAdditionalFile("db//student.mdb");
conn.Open(connStr, "", "");
axr = new ActiveXObject("ADODB.Recordset");
var rs = new _Recordset(axr.Identifier);
var sql = "select * from STUDENT where id>4";
rs.Open(sql,conn,1,2);
rs.MoveFirst();
var rsr:Array = rs.GetRows();
_root.id = rsr[0,1];
I expected that the result will be "Monica" (the 6th student's name) But it display "undefined" ! If I use this way: Code:
...... rs.MoveFirst(); var flds = new Fields(rs.Fields); var fld = new Field(flds.Item(0)); _root.id = fld.Value; this way , it works properly! why? How to use GetRows() ? |
|
|||
|
In the example floder(http://www.swfkit.com/forum/attachments/adodb.zip), there is a floder named "ADODB", there are many .as files in it......I think it's the class files that "import ADODB.*" required
Here's the code of _Recordset.as Code:
import SWFKit.*;
import flash.external.*;
class ADODB._Recordset extends SWFKit.ActiveXObject {
public function _Recordset(id: Number) {
...
}
....
public function get CursorType() {
return ExternalInterface.call("ffish_getprop", this.Identifier, "CursorType");
}
public function set CursorType(value) {
ExternalInterface.call("ffish_setprop", this.Identifier, "CursorType", value);
}
public function get EOF() {
return ExternalInterface.call("ffish_getprop", this.Identifier, "EOF");
}
public function get Fields() {
return ExternalInterface.call("ffish_getprop", this.Identifier, "Fields");
}
...
public function get RecordCount() {
return ExternalInterface.call("ffish_getprop", this.Identifier, "RecordCount");
}
......
public function AddNew() {
return ExternalInterface.call("ffish_call", this.Identifier, "AddNew", arguments);
}
...
public function GetRows() {
return ExternalInterface.call("ffish_call", this.Identifier, "GetRows", arguments);
}
...
public function Open(Source, ActiveConnection, CursorType, LockType) {
return ExternalInterface.call("ffish_call", this.Identifier, "Open", Source, ActiveConnection, CursorType, LockType);
}
public function Requery() {
...
}
public function _xResync() {
...
}
public function Update() {
...
}
public function get AbsolutePage() {
...
}
public function set AbsolutePage(value) {
...
}
...
public function get PageCount() {
...
}
public function get PageSize() {
...
}
public function set PageSize(value) {
...
}
...
public function get Index() {
...
public function Save(Destination) {
...
}
}
AbsolutePosition() BOF() CursorType(value) Fields() RecordCount() AddNew() GetRows() MoveNext() MoveFirst() MoveLast() Open(Source, ActiveConnection, CursorType, LockType) AbsolutePage() ...... ...... I want to know which functions are available? All I want to do is just read my database(student.mdb), and make a list of the record, Of course, there are many records in the student.mdb, so I want to divide them into many pages. Hence , operating the database involves many ADO functions, I want to know which functions are available in the SWFKit? |
|
|||
|
That is the wrapper class of the RecordSet object, an object exposed by the ADODB ActiveX component. Almost all methods and properties of ADODB can be accessed in swfkit except "GetRows".
|
|
|||
|
We have built a patch so that swfkit can now receive 2-dimensional arrays from ActiveX components. That is to say, the "GetRows" method will work well in actionscript. Please tell us which edition of swfkit you are using, swfkit or swfkit pro. We will send you the patch.
|
|
|||
|
Great Work!
Thank you very much! And I've tried the rs.PageSize rs.AbsolutePage rs.PageCount.....All of them work well! I' m using SWFKit 3.11 Email: xygbeta@gmail.com And another question: Code:
......
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Global.getAdditionalFile("student.mdb");
var ax = new ActiveXObject("ADODB.Connection");
var conn = new _Connection(ax.Identifier);
// Connecting to the database
conn.Open(connString, "", "");
....
Code:
conn.Open(connString,"","123"); Thanks a lot! |
|
|||
|
A password should be set in the connection string like
Code:
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Global.getAdditionalFile("student.mdb") + ";Jet OLEDB:Database Password=youpassword";
|
|
|||
|
Thank you again!
I've got a big problem with "dividing the recordset to many pages" In the first keyframe I call a functon which can connect to database, and display the recordset: Code:
showList("where id>0", 1);
// there's a ComboBox , which can switch to the other pages
var pgListener:Object = new Object();
pgListener.change = function(e:Object) {
removeMovieClip("sComboxMc"); // remove the previous ComboBox
showList("where id>0", e.target.selectedItem.data) // show the other page
}
sCombox.addEventListener("change", pgListener);
"1" will communicate to the "rs.AbsolutePage" , that mean the first page. showList() function's code is here: Code:
function showList(whereCond, whichPage){
var ax = new ActiveXObject("ADODB.Connection");
var conn = new _Connection(ax.Identifier);
var connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Global.getAdditionalFile("student.mdb");
conn.Open(connStr, "", "");
axr = new ActiveXObject("ADODB.Recordset");
var rs = new _Recordset(axr.Identifier);
var sql = "select * from student " + whereCond;
rs.Open(sql,conn,1,2);
rs.PageSize = perPage; //perPage is a variable, its first value is 10
allPages = rs.PageCount;
allRcd = rs.RecordCount;
rs.AbsolutePage = whichPage;
while (not rs.EOF and perPage > 0) {
var flds = new Fields(rs.Fields);
.....// show the fields
flds.Release();
rs.MoveNext();
perPage -= 1;
}
// add a ComboBox to show the navigator of pages
sComboxMc = this.createClassObject(mx.controls.ComboBox, "sCombox",1);
for (var j=1; j<=pageCnt; j++) {
sCombox.addItem({data:j, label:"Page"+j});
}
sCombox.setSize(85,22); //ComboBox's size
sCombox.move(100,100); //its (x,y) position
conn.Release();
rs.Release();
}
The First Page shows properly. The ComboBox shows properly too. Then I change the ComboBox, select the second item(the value is "2",second pge), it crashs! it can't show the second page's record! and the swfkit says: Code:
ADODB.Recordset:Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.. See also: C:\WINDOWS\HELP\ADO270.CHM. Thanks for advance! |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|