I usually program databases using ADODB.Connections, ADODB.Recordsets and Command objects.
I create the connection and command objects this way (I'm connecting to an Access database):
Set conect = New ADODB.Connection
conect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\Passwords.mdb"
conect.Open
Set com = New Command
com.ActiveConnection = conect
In another part of my program, I use the command object to insert registers this way:
com.CommandText = "INSERT INTO Usuarios (Num,Usuario,Password) VALUES (" + txtNo + ",'" + txtUsuario + "','" + txtPassword + "')"
com.Execute
(the txtNo, txtUsuario and txtPassword are Textbox controls on the form).
In most of my applications it works, but in other apps I get an error, saying that there is a syntax error in the SQL INSERT instruction, even if the SQL command is correct (I try the same command in Access and it works).
What is wrong?
Thanks
I create the connection and command objects this way (I'm connecting to an Access database):
Set conect = New ADODB.Connection
conect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\Passwords.mdb"
conect.Open
Set com = New Command
com.ActiveConnection = conect
In another part of my program, I use the command object to insert registers this way:
com.CommandText = "INSERT INTO Usuarios (Num,Usuario,Password) VALUES (" + txtNo + ",'" + txtUsuario + "','" + txtPassword + "')"
com.Execute
(the txtNo, txtUsuario and txtPassword are Textbox controls on the form).
In most of my applications it works, but in other apps I get an error, saying that there is a syntax error in the SQL INSERT instruction, even if the SQL command is correct (I try the same command in Access and it works).
What is wrong?
Thanks