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

Cursors with ADO

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Related Topics:
runtime error 3021 and user permissions - I have a VB6 that uses ADO 2.7 to access an database. I have found on Windows XP and 2000, that if the user is not part of the group, they receive: error 3021. Either BOF or EOF is true, or the current record..

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

ADO Connection Access Database VB - I have been accessing a database on a local drive thru an ADO The following is the code that I have been using. Security The problem is now I have..

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a for example after 5 records printed. Thank you all

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 record after the first line of..
Next:  Query Last Months Entries  
Author Message
rikesh patel

External


Since: Feb 16, 2005
Posts: 2



(Msg. 1) Posted: Wed Feb 16, 2005 7:40 pm
Post subject: Cursors with ADO
Archived from groups: microsoft>public>vb>database>ado (more info?)

Hi

I am trying to execute an SP which contains cursors etc....but when I create
the RS using ADO, I seem to get an error?

Is there something wrong with executing SP's of this type through VB using
ADO?

Below is a sample of the code I use:

'**************************************************
Set mrsRpt = New ADODB.Recordset
Set cmd1 = New ADODB.Command
Set cnn1 = New ADODB.Connection



sconnect = "Provider=SQLOLEDB.1;Password = " & mstrPassword & _
";Persist Security Info=True;User ID= " & mstrUser & _
";Initial Catalog=" & mstrDatabase & ";Data Source=" &
mstrServer



'Creates Connection information (NOTE: Server-Side cursor much faster.
With cnn1
.CursorLocation = adUseServer
.CommandTimeout = 0
.Open sconnect

End With

'Creates Command information
With cmd1
.ActiveConnection = cnn1
.CommandText = "exec " & txtSPName & " " & txtParam
.CommandType = adCmdText
.CommandTimeout = 0
End With



mrsRpt.Open cmd1.CommandText, cnn1, adOpenDynamic, adLockBatchOptimistic
'**************************************************



Kind Regards

Rikesh
(VB6 SP5)

 >> Stay informed about: Cursors with ADO 
Back to top
Login to vote
Richard J

External


Since: Aug 13, 2004
Posts: 2



(Msg. 2) Posted: Thu Feb 17, 2005 6:43 am
Post subject: RE: Cursors with ADO [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Take a look at the Parameters collection in the ADO Command object. That
will give you a good start.

Your command text is incorrect. Try:
With cmd1
.ActiveConnection = cnn1
.CommandText = txtSPName.Text
.CommandType = adCmdText
.CommandTimeout = 0
End With

Next, you will want to create a parameter using the .CreateParameter method
on the command object to create the parameter name, data type, input/output
direction, and length (if a character parameter).

Append this parameter object to the command object using
cmd1.Parameters.Append <parm object>.

Finally, set the value of the parameter using
cmd1.Parameters(<parmname>).Value = txtParm.Text

Once your parameter is created, appended, and set, you can execute your
query just like you have it in your message.

But again, I would start with the BOL and look up the ADO Parameter object.
That will go a long way in answering any specific questions that you might
have after reading this response.

I do hope this helps. Good luck.
Richard

"rikesh patel" wrote:

 > Hi
 >
 > I am trying to execute an SP which contains cursors etc....but when I create
 > the RS using ADO, I seem to get an error?
 >
 > Is there something wrong with executing SP's of this type through VB using
 > ADO?
 >
 > Below is a sample of the code I use:
 >
 > '**************************************************
 > Set mrsRpt = New ADODB.Recordset
 > Set cmd1 = New ADODB.Command
 > Set cnn1 = New ADODB.Connection
 >
 >
 >
 > sconnect = "Provider=SQLOLEDB.1;Password = " & mstrPassword & _
 > ";Persist Security Info=True;User ID= " & mstrUser & _
 > ";Initial Catalog=" & mstrDatabase & ";Data Source=" &
 > mstrServer
 >
 >
 >
 > 'Creates Connection information (NOTE: Server-Side cursor much faster.
 > With cnn1
 > .CursorLocation = adUseServer
 > .CommandTimeout = 0
 > .Open sconnect
 >
 > End With
 >
 > 'Creates Command information
 > With cmd1
 > .ActiveConnection = cnn1
 > .CommandText = "exec " & txtSPName & " " & txtParam
 > .CommandType = adCmdText
 > .CommandTimeout = 0
 > End With
 >
 >
 >
 > mrsRpt.Open cmd1.CommandText, cnn1, adOpenDynamic, adLockBatchOptimistic
 > '**************************************************
 >
 >
 >
 > Kind Regards
 >
 > Rikesh
 > (VB6 SP5)
 >
 >
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Cursors with ADO 
Back to top
Login to vote
Lishi Liu MSFT

External


Since: Sep 22, 2003
Posts: 18



(Msg. 3) Posted: Tue Feb 22, 2005 6:40 pm
Post subject: RE: Cursors with ADO [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

If your server is SQL Server,
  The server side cursor does not support Dynamic cursor on stored
procedure,
and adLockBatchOptimistic is implemented on client cursor, not on server
side.
You may want to use client side cursor on the "CursorLocation" property.

lishil, VSData team
--------------------
 >From: "rikesh patel" <trikky.TakeThisOut@rukp28.freeserve.co.uk>
 >Subject: Cursors with ADO
 >Date: Wed, 16 Feb 2005 23:08:06 -0000
 >Lines: 54
 >X-Priority: 3
 >X-MSMail-Priority: Normal
 >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
 >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
 >Message-ID: <epjjGzHFFHA.3972.TakeThisOut@TK2MSFTNGP15.phx.gbl>
 >Newsgroups: microsoft.public.vb.database.ado
 >NNTP-Posting-Host: modem-96.barahir.dialup.pol.co.uk 62.136.134.224
 >Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
 >Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.vb.database.ado:5236
 >X-Tomcat-NG: microsoft.public.vb.database.ado
 >
 >Hi
 >
 >I am trying to execute an SP which contains cursors etc....but when I
create
 >the RS using ADO, I seem to get an error?
 >
 >Is there something wrong with executing SP's of this type through VB using
 >ADO?
 >
 >Below is a sample of the code I use:
 >
 >'**************************************************
 >Set mrsRpt = New ADODB.Recordset
 >Set cmd1 = New ADODB.Command
 >Set cnn1 = New ADODB.Connection
 >
 >
 >
 > sconnect = "Provider=SQLOLEDB.1;Password = " & mstrPassword & _
 > ";Persist Security Info=True;User ID= " & mstrUser & _
 > ";Initial Catalog=" & mstrDatabase & ";Data Source=" &
 >mstrServer
 >
 >
 >
 > 'Creates Connection information (NOTE: Server-Side cursor much faster.
 > With cnn1
 > .CursorLocation = adUseServer
 > .CommandTimeout = 0
 > .Open sconnect
 >
 > End With
 >
 > 'Creates Command information
 > With cmd1
 > .ActiveConnection = cnn1
 > .CommandText = "exec " & txtSPName & " " & txtParam
 > .CommandType = adCmdText
 > .CommandTimeout = 0
 > End With
 >
 >
 >
 > mrsRpt.Open cmd1.CommandText, cnn1, adOpenDynamic, adLockBatchOptimistic
 >'**************************************************
 >
 >
 >
 >Kind Regards
 >
 >Rikesh
 >(VB6 SP5)
 >
 >
 >
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Cursors with ADO 
Back to top
Login to vote
rikesh patel

External


Since: Feb 16, 2005
Posts: 2



(Msg. 4) Posted: Wed Mar 23, 2005 6:10 pm
Post subject: Re: Cursors with ADO [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

If this is so, then what settings should i use for my CMD object or the
Connection objects?
Kind Regards

Rikesh

"Lishi Liu [MSFT]" <lishil.RemoveThis@online.microsoft.com> wrote in message
news:bINSPGTGFHA.2424@TK2MSFTNGXA02.phx.gbl...
>
>
> If your server is SQL Server,
> The server side cursor does not support Dynamic cursor on stored
> procedure,
> and adLockBatchOptimistic is implemented on client cursor, not on server
> side.
> You may want to use client side cursor on the "CursorLocation" property.
>
> lishil, VSData team
> --------------------
> >From: "rikesh patel" <trikky.RemoveThis@rukp28.freeserve.co.uk>
> >Subject: Cursors with ADO
> >Date: Wed, 16 Feb 2005 23:08:06 -0000
> >Lines: 54
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> >Message-ID: <epjjGzHFFHA.3972.RemoveThis@TK2MSFTNGP15.phx.gbl>
> >Newsgroups: microsoft.public.vb.database.ado
> >NNTP-Posting-Host: modem-96.barahir.dialup.pol.co.uk 62.136.134.224
> >Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
> >Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.vb.database.ado:5236
> >X-Tomcat-NG: microsoft.public.vb.database.ado
> >
> >Hi
> >
> >I am trying to execute an SP which contains cursors etc....but when I
> create
> >the RS using ADO, I seem to get an error?
> >
> >Is there something wrong with executing SP's of this type through VB
using
> >ADO?
> >
> >Below is a sample of the code I use:
> >
> >'**************************************************
> >Set mrsRpt = New ADODB.Recordset
> >Set cmd1 = New ADODB.Command
> >Set cnn1 = New ADODB.Connection
> >
> >
> >
> > sconnect = "Provider=SQLOLEDB.1;Password = " & mstrPassword & _
> > ";Persist Security Info=True;User ID= " & mstrUser & _
> > ";Initial Catalog=" & mstrDatabase & ";Data Source=" &
> >mstrServer
> >
> >
> >
> > 'Creates Connection information (NOTE: Server-Side cursor much faster.
> > With cnn1
> > .CursorLocation = adUseServer
> > .CommandTimeout = 0
> > .Open sconnect
> >
> > End With
> >
> > 'Creates Command information
> > With cmd1
> > .ActiveConnection = cnn1
> > .CommandText = "exec " & txtSPName & " " & txtParam
> > .CommandType = adCmdText
> > .CommandTimeout = 0
> > End With
> >
> >
> >
> > mrsRpt.Open cmd1.CommandText, cnn1, adOpenDynamic,
adLockBatchOptimistic
> >'**************************************************
> >
> >
> >
> >Kind Regards
> >
> >Rikesh
> >(VB6 SP5)
> >
> >
> >
> >
>
 >> Stay informed about: Cursors with ADO 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada) (change)
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 ]