AutoHotkey Community

It is currently May 27th, 2012, 12:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: December 24th, 2009, 3:57 am 
Offline

Joined: December 24th, 2009, 3:47 am
Posts: 5
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()
}


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 27th, 2009, 10:27 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2009, 2:57 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
FYI if you want to work with true arrays you should take a look into AutoHotkey_L.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], WillTroll, XstatyK, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group