|
-
Sep 9th, 2002, 08:11 AM
#1
Thread Starter
Member
simple db question
How do I run an insert query against a db using the Ado Data Control, assuming I have the adodc already connected to the db I want to use?
Can you show me the code...
Thank you very much
-----------------
To steal ideas from one person is plagiarism;
to steal from many is research.
Visual Poet :^)
-
Sep 9th, 2002, 08:29 AM
#2
Frenzied Member
If you are already connected then to insert a new record first use Recordset.AddNew, enter the values you require then update the recordset using Recordset.Update.
HTH
DJ
-
Sep 9th, 2002, 08:42 AM
#3
Thread Starter
Member
Sorry I meant that I already have a SQL expression that would do some moving of data from one table to another - insert then delete - so the expression is ready and all I need is to execute it as a query... how can I do that?
Thanks a lot for your help and sorry for not explaining myself so well....
VP
-----------------
To steal ideas from one person is plagiarism;
to steal from many is research.
Visual Poet :^)
-
Sep 9th, 2002, 08:46 AM
#4
Frenzied Member
Could you post the code you have so far to connect to the database.
-
Sep 9th, 2002, 01:02 PM
#5
Thread Starter
Member
Here's My CODE
I am not sure where to put the query I want to run, so I put it in the recordsource property of the adodc...... but I bet that's not the place to put it... all I need is to run this sql statement againt the db without returning any results.... thx
Code:
Private Sub cmdGo_Click()
On Error GoTo Err
adoReport.CommandType = adCmdText + adExecuteNoRecords
adoReport.RecordSource = "INSERT INTO SongRequestBak SELECT * From songrequest WHERE (WellReceived = 1)AND (ID < (SELECT MAX(id) FROM songrequest))DELETE FROM songrequest WHERE (WellReceived = 1)AND (ID < (SELECT MAX(id) FROM songrequest))"
Exit Sub
Err:
MsgBox Err.Description, vbOKOnly, "Error"
Screen.MousePointer = vbDefault
End Sub
-----------------
To steal ideas from one person is plagiarism;
to steal from many is research.
Visual Poet :^)
-
Sep 9th, 2002, 01:54 PM
#6
Hyperactive Member
Try:
VB Code:
adoReport.Database.Execute (""INSERT INTO SongRequestBak SELECT * From songrequest WHERE (WellReceived = 1)AND (ID < (SELECT MAX(id) FROM songrequest))DELETE FROM songrequest WHERE (WellReceived = 1)AND (ID < (SELECT MAX(id) FROM songrequest))")
-
Sep 9th, 2002, 03:50 PM
#7
Thread Starter
Member
I am so glad that we too think alike, but this method doesnt' exist.....!!
adodc.database <---- doesn't exist
adodc.recordset <---- exists but without the execute method
anyway out?
Thx a lot, I thought this was an easy problem, but I didn't know it would take so much thinking.....
VP
-----------------
To steal ideas from one person is plagiarism;
to steal from many is research.
Visual Poet :^)
-
Sep 9th, 2002, 03:58 PM
#8
Fanatic Member
execute is a connection object method. So you can try :
set cn = adodc1.Recordset.ActiveConnection
cn.Execute sqlstring
VB 6.0, Access, Sql server, Asp
-
Sep 9th, 2002, 04:00 PM
#9
Hyperactive Member
If you have it, you would be better off referencing Microsoft Access 8.0 Data Object Library. Then you will have the methods you need.
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
|