ADO recordset without connection 
Author Message
 ADO recordset without connection

Hi,

I created new recordset object and appended some fields to the new recordset
which does't know about any database or query and open the recordset with
out any connection and query.
Then I added some records into the recordset and now I want to save this
data into the database.
How to save records from the recordset to the database?
Please anyone help me in this regard.

Here is the code

Dim rs as new ADORecordset

rs.fields.append "FirstName",adChar,10
rs.fields.append "LastName",adChar,10
rs.open

'Add New data
rs.AddNew
rs.fields(1).value = "John"
rs.fields(2).value = "Bolton"
rs.Update

Then now i want to update this record into database by connection string and
query,How to do that?

Thanks
Mukkara



Sun, 30 Nov 2003 07:00:50 GMT  
 ADO recordset without connection
create a dummy table employee(firstname,lastname)
create a dsn "test" which points to your database
dim cn as adodb.connection
dim sql as string
cn.open "test"
sql="insert into employee(firstname,lastname) values ("
+ rs(0)+"," + rs(1)+")"
cn.execute sql

Brainbench certified VB6 and SQL7 developer
Home Page: http://partha.tripod.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 30 Nov 2003 07:57:49 GMT  
 ADO recordset without connection
Hi,

Thanks for your reply it works, Is there any other way of doing this.Since I am holding the data in a recordset which does't know any thing about database and query.

I got connection object,query string and want to pass to the recordset and update the records.

Explanation of Scenario is user want to add some brand new data into the table(which already has thousands of records) from a Form.So I created a recordset with all the fields on the form(represents multiple tables columns).User enters data and now he wants to save this record into the database.

I know the dsn and Query string but i want to pass this information to the recordset and execute update.Is it possible or do we have any other way of doing this.

Thanks
Mahesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 30 Nov 2003 20:57:54 GMT  
 ADO recordset without connection
An easy way to do this is to open the recordset against the table with a
query that returns no records.

rst.open "select * from T where 1=2",cn

Then you can do

    rst.addnew

to add records to this table.

David


Hi,

Thanks for your reply it works, Is there any other way of doing this.Since I
am holding the data in a recordset which does't know any thing about
database and query.

I got connection object,query string and want to pass to the recordset and
update the records.

Explanation of Scenario is user want to add some brand new data into the
table(which already has thousands of records) from a Form.So I created a
recordset with all the fields on the form(represents multiple tables
columns).User enters data and now he wants to save this record into the
database.

I know the dsn and Query string but i want to pass this information to the
recordset and execute update.Is it possible or do we have any other way of
doing this.

Thanks
Mahesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 01 Dec 2003 06:52:07 GMT  
 ADO recordset without connection
Thanks David it works.I feel this is the easiest way of solving this.It
means we have to give a call to database one way or other to open the
recordset to populate only the fields information.


Quote:
> An easy way to do this is to open the recordset against the table with a
> query that returns no records.

> rst.open "select * from T where 1=2",cn

> Then you can do

>     rst.addnew

> to add records to this table.

> David



> Hi,

> Thanks for your reply it works, Is there any other way of doing this.Since
I
> am holding the data in a recordset which does't know any thing about
> database and query.

> I got connection object,query string and want to pass to the recordset and
> update the records.

> Explanation of Scenario is user want to add some brand new data into the
> table(which already has thousands of records) from a Form.So I created a
> recordset with all the fields on the form(represents multiple tables
> columns).User enters data and now he wants to save this record into the
> database.

> I know the dsn and Query string but i want to pass this information to the
> recordset and execute update.Is it possible or do we have any other way of
> doing this.

> Thanks
> Mahesh

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Tue, 02 Dec 2003 00:08:02 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Using a RecordSet without an ADO connection

2. Collection of ADO Recordsets and/or ADO Connections

3. How to fill a RecordSet without a connection

4. Make a recordset without a connection

5. Recordset without connection

6. ADO-Connection to Dbase without DNS

7. Using ADO WITHOUT a DB-connection

8. Resorting an Ado recordset without reopening it.

9. Retrieve data without trailing space with ADO recordset?

10. How many ADO recordsets can share a connection ?

11. Detecting how many recordsets are using an ADO connection

12. Multiple recordsets for a single ADO connection???

 

 
Powered by phpBB® Forum Software