Jochem Posted September 29, 2009 Posted September 29, 2009 I am trying to put a array into a database, but what am I doing wrong;I get this error:! SQLite.au3 Error --> Function: _SQLite_Exec --> Query: INSERT INTO computer VALUES (WS-C104,'test') --> Error: no such column: C104expandcollapse popup#include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global $aCompList = _netwerklist(0x1) Global $host, $hQuery, $aRow, $aResult, $iRows, $iColumns, $iRval _SQLite_Startup() _SQLite_Open() _SQLite_Exec(-1, "Create table computer (comp, user)") For $host In $aCompList _SQLite_Exec(-1, "INSERT INTO computer VALUES (" & $host & ",'test')") Next $itest = _SQLite_GetTable2d(-1, "SELECT * FROM computer;", $aResult, $iRows, $iColumns) _ArrayDisplay($aResult, "Query Result") _SQLite_Close() _SQLite_Shutdown() ;=============================================================================== ; ; Function Name: _netwerklist($iSrvType = -1, $sDomain = '') ; Description: maakt via dllcal de network list (fast) ; Parameter(s): none ; Requirement(s): none ; Return Value(s): Returns een 1d array with computers ; Author(s): ????? ; ;=============================================================================== Func _netwerklist($iSrvType = -1, $sDomain = '') Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1] = [0], $i Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord) Local $uString = DllStructCreate("char[16]") Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0 If Not ($sDomain = '' Or $sDomain = '*') Then DllStructSetData($uDomain, 1, StringToBinary($sDomain, 2)) $pDomain = DllStructGetPtr($uDomain) EndIf Local $ret = DllCall("netapi32.dll", "int", "NetServerEnum", _ "ptr", 0, "int", 100, _ "ptr", DllStructGetPtr($uBufPtr, 1), "int", -1, _ "ptr", DllStructGetPtr($uBufPtr, 2), _ "ptr", DllStructGetPtr($uBufPtr, 3), _ "int", $iSrvType, "ptr", $pDomain, "int", 0) If $ret[0] Then Return SetError(1, $ret[0], '') Local $res[DllStructGetData($uBufPtr, 3) + 1] = [DllStructGetData($uBufPtr, 3)] For $i = 1 To DllStructGetData($uBufPtr, 3) Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr, 1) + ($i - 1) * $iRecLen) Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord, 2)) DllStructSetData($uString, 1, BinaryToString(DllStructGetData($sNBName, 1), 2)) $res[$i] = DllStructGetData($uString, 1) Next $ret = DllCall("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr, 1)) Return $res EndFunc ;==>_netwerklist
PsaltyDS Posted September 29, 2009 Posted September 29, 2009 You lost the single quotes around the $host value to indicate a literal string. Try: For $host In $aCompList _SQLite_Exec(-1, "INSERT INTO computer VALUES ('" & $host & "','test')") Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
supahfly Posted September 29, 2009 Posted September 29, 2009 Your insert query is wrong.... The column names are not defined. you need to do like this. _SQLite_Exec(-1,"INSERT INTO (comp, user) VALUES ('" & $host & "','test')")
Jochem Posted September 29, 2009 Author Posted September 29, 2009 You lost the single quotes around the $host value to indicate a literal string. Try: For $host In $aCompList _SQLite_Exec(-1, "INSERT INTO computer VALUES ('" & $host & "','test')") Next great this is working, thanks
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