after studying more on this, now i learned how to do this;
to clarify the example above:
this is an example of how to connect to a databaseyou should change some parameters in the code to use it on your own database file,
most important ones are these:
1. [dbfile path]: the database file's path that you want to connect to it
ex: in here it's: 'D:\MyData\DB\waste.mdb'
2. [TableName]: the table name in the your db file
ex: in here it's: "Items"
3. [FieldName]: the Field you want to do something on it
ex: in here it's: "Item_des"
=================
Important Note:Xwidget uses javascript mode by default
to change between javascript/vbscript:1. open Xwidget Designer
2. from the left Sidebar (Widget tree view), select [Widget Attributes], [widget Attribute] form will be shown
3. from this form, find [Script Lang] dropdown menu, and select one that you desire (JavaScript/VBScript)
4. now in Script Editor you can write the code in the language you have selected
================
this is a VBScript code: (use it if you are using your widget in VBScript code, not the JavaScript code)
Code:
Sub button2OnClick(Sender)
Dim strConnection, conn, rs, strSQL
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='D:\MyData\DB\waste.mdb'"
Set conn = CreateObject("ADODB.Connection")
conn.Open(strConnection)
Set rs = CreateObject("ADODB.recordset")
strSQL = "Select * from Items"
rs.Open strSQL,conn
rs.MoveFirst
while not rs.EOF
Print(rs("Item_des"))
rs.MoveNext
WEND
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
JavaScript version of same code is this:(use this if you're using your widget in JavaScript mode)
Code:
function button2OnClick(Sender)
{
var strConnection, conn, rs, strSQL
strConnection = "Provider= Microsoft.Jet.OLEDB.4.0 ;Data Source='D:\MyData\DB\waste.mdb'"
conn = new ActiveXObject("ADODB.Connection");
conn.Open(strConnection)
rs = new ActiveXObject("ADODB.recordset")
strSQL = "Select * from Items"
rs.Open(strSQL,conn)
rs.MoveFirst()
while(!rs.EOF)
{
Print(rs("Item_des"))
rs.MoveNext()
}
rs.Close()
rs = null
conn.Close()
conn = null
}