Jump to content

How to use variables?


9LUCAS
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...