|
-
Nov 23rd, 2000, 10:34 PM
#1
Thread Starter
Lively Member
Hi,
How do I use UPDATE and INSERT type SQL statements in a database and recordset declared in code?
I use the following for SELECT statements:
Code:
SQL = "SELECT * FROM Employees"
Set db = OpenRecordset(dbPath)
Set rs = db.OpenRecordset(SQL)
I can't seems to get rs.Execute(SQL) to work. What am I doing wrong?
Thanks in advance.
-
Nov 24th, 2000, 05:03 AM
#2
Lively Member
I've been doing it this way:
Code:
StrSQL = "INSERT INTO " & Table_Name & _
" (" & StrFields & ") " & _
" VALUES (" & StrValues & ")"
'Debug.Print StrSQL
Dim cmd as ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnDB
cmd.CommandText = StrSQL
cmd.Execute
Set cmd = Nothing
-
Nov 24th, 2000, 08:44 PM
#3
Thread Starter
Lively Member
-
Nov 25th, 2000, 12:04 AM
#4
Well ...
I do it in DAO as this:
Code:
SQL = "Update ......"
dbMaster.Execute SQL
If you are not getting this right, maybe you are using parenthesis around the query, like:
Code:
SQL = "Update ...."
dbMaster.Execute(SQL)
Try omitting the parenthesis and it should work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|