 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
iyerushalmi
Joined: 24 Dec 2009 Posts: 5
|
Posted: Thu Dec 24, 2009 2:57 am Post subject: EZ Question- Retrieving MDB Records using an Array + Com.ahk |
|
|
I am making an AHK to create/edit/delete records in a Microsoft Access Database. I am new to AHK and have a question.
I am writing a library of functions to call upon when working with the database. I would like the function below to store the retrieved record into an array for easy access to all fields in that record.
Currently everything is simply stored into one variable: sData. Can anyone please help? It would be greatly appreciated!
| Code: | GetProduct(SKU) {
sSource := "SELECT * FROM " . "Products" . " WHERE SKU = '" . SKU . "'"
sConnect := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . "C:\Documents and Settings\TheBeadChest.com\Desktop\scripts\addtoinv\Inventory.mdb"
COM_Init()
prs := COM_CreateObject("ADODB.Recordset")
COM_Invoke(prs, "Open", sSource, sConnect)
Loop
{
If COM_Invoke(prs, "EOF")
Break
pFields := COM_Invoke(prs, "Fields")
Loop, % COM_Invoke(pFields, "Count")
pField:= COM_Invoke(pFields, "Item", A_Index-1)
, sData .= COM_Invoke(pField, "Name") . ": " . COM_Invoke(pField, "Value") . "`r`n"
, COM_Release(pField)
COM_Release(pFields)
COM_Invoke(prs, "MoveNext")
}
COM_Invoke(prs, "Close")
COM_Release(prs)
COM_Term()
}
|
|
|
| Back to top |
|
 |
hd0202
Joined: 13 Aug 2006 Posts: 265 Location: Germany
|
Posted: Sun Dec 27, 2009 9:27 am Post subject: Re: EZ Question- Retrieving MDB Records using an Array + Com |
|
|
try this:
| Code: | sField%A_Index% := COM_Invoke(pField, "Name") . ": " . COM_Invoke(pField, "Value")
sName%A_Index% := COM_Invoke(pField, "Name")
sValue%A_Index% := COM_Invoke(pField, "Value")
|
Hubert |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|