Jewtus Posted October 28, 2014 Share Posted October 28, 2014 (edited) Func GetRecords($DB,$Query,$OutputVar) Local $aResult, $iRows, $iColumns $iRval = _SQLite_GetTable2d(-1, $Query &";", $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then _ArrayDisplay($aResult) Else MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf EndFunc GetRecords($sqlDB,"Select Name,EMAIL,PHONE,Cost,Depart,Distr,Bran from TeamMemberListing where [Network_ID] Like '"&$NetID&"'",$Results) _ArrayDisplay($Results) $Name = $Results[1][0] $Email = $Results[1][1] $Phone = $Results[1][2] $Cost = $Results[1][3] $Depart = $Results[1][4] $Distr = $Results[1][5] $Bran = $Results[1][6] Above is the code I'm executing. The array pops up without any issue, but when I get an error trying to assign the array variable "C:Sourcesautoit basedSALESSALES.au3" (117) : ==> Subscript used on non-accessible variable.: $Name = $Results[1][0] $Name = $Results^ ERROR ->09:42:05 AutoIt3.exe ended.rc: I've even change it to [0][0] just to see if it would pull the value and it still gives that error. Are SQLite return arrays different somehow? Edited October 28, 2014 by Jewtus Link to comment Share on other sites More sharing options...
BrewManNH Posted October 28, 2014 Share Posted October 28, 2014 $Results isn't set to anything in your function, so it's not returning anything to see in the array.You send it to the $OutputVar parameter, but never use it in the function. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Jewtus Posted October 28, 2014 Author Share Posted October 28, 2014 I'm not sure I understand... The array does show up and there is data in the array... this is the output (copy data&hdr/row) from the array: Row|Col 0|Col 1|Col 2|Col 3|Col 4|Col 5 [0]|Name|EMAIL|PHONE|Cost|Depart|Distr|Bran [1]|name|Test@email.com|555-555-5555|123|123|123 Shouldn't $Name = $Results[0][0] give me back "Name" Link to comment Share on other sites More sharing options...
BrewManNH Posted October 28, 2014 Share Posted October 28, 2014 You have an _ArrayDisplay in your function displaying the contents of $aResult, that array is not the same as the $Results variable in the second _ArrayDisplay outside of the function. $aResult is a local variable only visible and accessible inside your function. I'm not sure what $Results is as far as the type of variable it is because you don't declare it in your snippet. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Jewtus Posted October 28, 2014 Author Share Posted October 28, 2014 Oh man... I'm a fool Thank you so much! When I tweaked the function to be: Func GetRecords($DB,$Query) Local $aResult, $iRows, $iColumns $iRval = _SQLite_GetTable2d(-1, $Query &";", $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then Return $aResult Else MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf EndFunc it worked fine. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now