Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ADODB.RecordSet

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Next:  Non-admins cannot connect on SQL 2000  
Author Message
Paulo Roberto

External


Since: Dec 02, 2009
Posts: 1



(Msg. 1) Posted: Wed Dec 02, 2009 7:25 am
Post subject: ADODB.RecordSet
Archived from groups: microsoft>public>vb>database>ado (more info?)

Hi, I have a client recordset returned via VB6. I'd like to know if it can
be inserted to a phisical table on MS SQL SERVER containing the same
fields...? It'd be like a "INSERT SELECT", but the source (select) would
come from this adodb.recordset.

I'd like to avoid looping every line of the recordset and generating "insert
into" instructions....

Thanks !

 >> Stay informed about: ADODB.RecordSet 
Back to top
Login to vote
Ralph

External


Since: Jan 28, 2008
Posts: 34



(Msg. 2) Posted: Wed Dec 02, 2009 7:44 am
Post subject: Re: ADODB.RecordSet [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Paulo Roberto" wrote in message

> Hi, I have a client recordset returned via VB6. I'd like to know if it can
> be inserted to a phisical table on MS SQL SERVER containing the same
> fields...? It'd be like a "INSERT SELECT", but the source (select) would
> come from this adodb.recordset.
>
> I'd like to avoid looping every line of the recordset and generating
"insert
> into" instructions....
>

No. Well, make that no way to do something as simple as ...

rsSQLSrvr = rsVB6

Consider for a second what a Recordset is - it is a Variant Collection of
Variant Collections (or Variant Arrays or Variant Arrays). There is no way
to make a simple copy - any copying would be a deep copy - meaning loop by
loop. ie, even if you had some routine like ...
copyRecordset( rsSQLSrvr, rsVB6)
It would simplify the coding - but internally it would just be looping. So
engineering your own 'deep' copy is not necessarily inelegant or
inefficient, and is often required if any unique translation is needed. (And
historically it always seems to become necessary eventually. <g>)

However, generating "insert into" instructions is not the only way.
You could dump the rsVB6 recordset into an XML or Text file and import it.
You might employ SPs to manage inserts.
You might employ some DTS scheme.
....
We really need to know more about your particular problem domain.

-ralph

 >> Stay informed about: ADODB.RecordSet 
Back to top
Login to vote
Romzky

External


Since: Dec 07, 2009
Posts: 1



(Msg. 3) Posted: Mon Dec 07, 2009 5:25 am
Post subject: Re: ADODB.RecordSet [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

hey there!

can anyone give me a code, how to connect mysql into vb?

romzky
 >> Stay informed about: ADODB.RecordSet 
Back to top
Login to vote
Ralph

External


Since: Jan 28, 2008
Posts: 34



(Msg. 4) Posted: Mon Dec 07, 2009 6:18 am
Post subject: Re: ADODB.RecordSet [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Romzky" wrote in message
> hey there!
>
> can anyone give me a code, how to connect mysql into vb?
>


http://www.connectionstrings.com/mysql
[Remember that site, it will become your friend for all connection
questions.]

Actual code would depend on the data access library, provider/driver, MySQL,
and the versions you are using.

-ralph
 >> Stay informed about: ADODB.RecordSet 
Back to top
Login to vote
Mark McGinty

External


Since: Apr 07, 2008
Posts: 7



(Msg. 5) Posted: Mon Dec 14, 2009 12:07 am
Post subject: Re: ADODB.RecordSet [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Paulo Roberto" wrote in message

> Hi, I have a client recordset returned via VB6. I'd like to know if it can
> be inserted to a phisical table on MS SQL SERVER containing the same
> fields...? It'd be like a "INSERT SELECT", but the source (select) would
> come from this adodb.recordset.
>
> I'd like to avoid looping every line of the recordset and generating
> "insert into" instructions....
>
> Thanks !

One fairly easy way is to persist the recordset to XML (see the Save
method), alter the XML, open a new recordset on the altered XML, connect it
to a SQL Server and call UpdateBatch. Instead of:

<rs:data>
<z:row field1="value" field2="value" [...] />
<z:row field1="value" field2="value" [...] />
[...]
</rs:data>

it becomes:

<rs:data>
<rs:insert>
<z:row field1="value" field2="value" [...] />
<z:row field1="value" field2="value" [...] />
[...]
<rs:insert>
</rs:data>

There are some conditions, no values can be present for identity columns,
computed or derived columns or columns that are inherently read-only for any
other reason. Also, in the schema section you may need to fixup the values
of the basetable and basecatalog attributes as appropriate.

More, the recordset itself must be writable (attribute/value
rs:updatable='true' present in the s:ElementType node) as well as each
column for which a value is supplied (attribute/value rs:writeunknown='true'
present in each s:AttributeType node.)

Note that it is possible to change the XML, as long as the change is valid
in the context of the server. For example, a recordset returned by calling
connection or command .Execute, or by executing a stored procedure as if it
were a method of a connection object is, to ADO, read-only, and this is
reflected in XML when it is persisted. However, this does not necessarily
mean that the underlying data elements on the server cannot be written. A
writable recordset can be created by manipulating the XML, provided those
manipulations are not invalid to the server.

It all sounds involved (perhaps because it is, in fact, quite involved) but
once you've worked out the details for your specific recordset[s] it's a
pretty simple transformation.


Good Luck,
Mark
 >> Stay informed about: ADODB.RecordSet 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
guru needed -> problem connecting to .dbf using ADODB - Hi, I been looking for answers for this problem and have not been very lucky. I'm trying to connect to a .dbf file from VB6 (Free table directory, for the sample below I have a dbfFileName.dbf file inside the folder App.Path & "\databases")...

updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..

ADO recordset question - Hello all. This is such a basic question, but I can't find an answer. I have a function in a class module that finds data from a series of database tables. The data, when found, is placed into a new recordset within the function. All OK here. Now, wher...

Recordset-adding to a Listview - I've got a weird problem - - - it must be something simple, but for the life of me, I must be missing it... I've got a recordset - and I'm trying to add the results into a listview, but, instead of adding each successive record after the first line of....

VB6 using ADO, sproc with return recordset - VB6 code snippet: with cmd .cmdtext = "exec buildwordlist 11" .commandtype = adcmdtext end with set rs = cmd.execute() if not rs.eof then strfield = rs!fieldname rs.movenext end if the above code works just fine if the sproc is ...
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]