English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i want to insert a record in a table with ADO ,and i wrote this code:
------------------------------------------------------------------------
Private Sub Command1_Click()
ado1.recordsource="insert into table1 values('a','b')"
ado1.refresh
End Sub
------------------------------------------------------------------------
but in run_time i see this error:
operation is not allowed when
the object is closed.
what can i do.

2006-08-03 03:53:46 · 3 answers · asked by Hossein 1 in Computers & Internet Programming & Design

3 answers

you should read about data and adodc property and if you working with code only you have to declare with starting of form with
dim RS as recordset
dim cn as connection

then in your programming wherever you want to execute your code write
set rs = new recordset
set cn = new connection
then you have to write a connection string and then you can your query

2006-08-03 04:04:02 · answer #1 · answered by ravi sagar 1 · 0 0

use "Execute" method of Connection object.
connection is a part of ADO control.

ADO1.CONNECTION.EXECUTE("insert into table1 values('a','b')")

2006-08-03 08:29:50 · answer #2 · answered by pratikmx 2 · 0 0

You have at first to open the Recordset
ado1.open
ado1.Add
ado1.field1 = 'a'
ado1.field2 = 'b'
ado1.update
ado1.refresh
adp1.close

Helmut

2006-08-03 04:02:02 · answer #3 · answered by hswes 2 · 0 0

fedest.com, questions and answers