9LUCAS Posted September 12, 2016 Share Posted September 12, 2016 Hi. I'm using a function to add information to an Access database. I want to add information from a variable that I have declared previously. When I open the file access. In the modified fields just appears "$campo", rather than the content of the variable ("campotest"). The function is: $FULL_MDB_FILE_NAME = @ScriptDir & "\MyDatabase.accdb" $SQL_CODE = "select * from Table_1" $CONN = ObjCreate("ADODB.Connection") $CONN.Open('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=' & $FULL_MDB_FILE_NAME & ';') $RecordSet = ObjCreate("ADODB.Recordset") $CONN.Execute("INSERT into Table_1 (Name, Campo1) values ('$campo', '45326')") $CONN.Close I declared the variables as follows: Global $campo = "campotest" I am declaring the variables correctly? Is there any error in function? Thanks in advance. PS: sorry for my English. Link to comment Share on other sites More sharing options...
Bowmore Posted September 12, 2016 Share Posted September 12, 2016 This line $CONN.Execute("INSERT into Table_1 (Name, Campo1) values ('$campo', '45326')") should be $CONN.Execute("INSERT into Table_1 (Name, Campo1) values ('" & $campo & "', '45326')") "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
9LUCAS Posted September 12, 2016 Author Share Posted September 12, 2016 2 minutes ago, Bowmore said: This line $CONN.Execute("INSERT into Table_1 (Name, Campo1) values ('$campo', '45326')") should be $CONN.Execute("INSERT into Table_1 (Name, Campo1) values ('" & $campo & "', '45326')") Thanks. Solved! 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