wjans Posted December 26, 2008 Share Posted December 26, 2008 When trying to execute the following function with a variable as column name I get ! SQLite.au3 Error --> Function: _SQLite_Exec --> Query: ALTER TABLE MedSERVEUsers ADD COLUMN 20080901 --> Error: near "20080901": syntax error When I add this without the variable it works fine. I tried all sorts of ", ' and ; but to no avail. Func Add_Column($colName) If Not _SQLite_Exec($hDB, "ALTER TABLE MedSERVEUsers ADD COLUMN " & $colName) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) EndIf MsgBox(1, "Add Column", "column " & $colName & " has been added") EndFunc ;==>Add_Column Link to comment Share on other sites More sharing options...
FireFox Posted December 26, 2008 Share Posted December 26, 2008 (edited) @wjans Perhaps this should work #include <SQLite.au3> Func Add_Column($colName) Local $hDB If Not _SQLite_Exec($hDB, "ALTER TABLE MedSERVEUsers ADD COLUMN " & $colName) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) EndIf MsgBox(64 , "Add Column", "Column " & $colName & " has been added") EndFunc ;==>Add_Column Edited December 26, 2008 by FireFox Link to comment Share on other sites More sharing options...
martin Posted December 26, 2008 Share Posted December 26, 2008 When trying to execute the following function with a variable as column name I get ! SQLite.au3 Error --> Function: _SQLite_Exec --> Query: ALTER TABLE MedSERVEUsers ADD COLUMN 20080901 --> Error: near "20080901": syntax error When I add this without the variable it works fine. I tried all sorts of ", ' and ; but to no avail. Func Add_Column($colName) If Not _SQLite_Exec($hDB, "ALTER TABLE MedSERVEUsers ADD COLUMN " & $colName) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) EndIf MsgBox(1, "Add Column", "column " & $colName & " has been added") EndFunc ;==>Add_ColumnUsing this to test, it looks like you have to enclose a number in quotes, so maybe this would work If Not _SQLite_E xec($hDB, 'ALTER TABLE MedSERVEUsers ADD COLUMN "' & $colName & '" INTEGER') = $SQLITE_OK Then Assumiung thecolumn is for integers. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
wjans Posted December 26, 2008 Author Share Posted December 26, 2008 Thanks for the reply. I didn't post the complete script, but opening the DB and executing SQL statements work OK, as long as I don't use a variable ... @wjans Perhaps this should work #include <SQLite.au3> Func Add_Column($colName) Local $hDB If Not _SQLite_Exec($hDB, "ALTER TABLE MedSERVEUsers ADD COLUMN " & $colName) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) EndIf MsgBox(64 , "Add Column", "Column " & $colName & " has been added") EndFunc ;==>Add_Column Link to comment Share on other sites More sharing options...
wjans Posted December 26, 2008 Author Share Posted December 26, 2008 @Martin, adding the type solved the problem Thanks. 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