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

updatable ado-recordset

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Related Topics:
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, where

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..

VB6 using ADO, sproc with return recordset - VB6 code snippet: with cmd .cmdtext = 11" = adcmdtext end with set rs = if not rs.eof then strfield = end if the above code works just fine if the sproc is a simple..

Updating An ADO 2.6 Recordset With VB and Access - When I try to update my ADO Recordset like this: = I get this: Current Recordset does not support updating. This may be a of the provider, or of the selected locktype. Error 3251 When I try to..

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..
Next:  arrays  
Author Message
Jason

External


Since: Feb 18, 2005
Posts: 7



(Msg. 1) Posted: Tue Feb 22, 2005 3:41 pm
Post subject: updatable ado-recordset
Archived from groups: microsoft>public>vb>database>ado (more info?)

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 ADODB.Connection

Public Function GetConnection(ByVal boolOpenIfClosed As Boolean) As
ADODB.Connection

If mconn Is Nothing Then
Set mconn = New ADODB.Connection
With mconn
.Provider = "MSDataShape"
.ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA
SOURCE=local;DATABASE=test;UID=sa;PWD=;"
.CursorLocation = adUseServer
.Open
End With
End If
If mconn.State = adStateClosed Then
If boolOpenIfClosed Then
mconn.Open
End If
End If

Set GetConnection = mconn

End Function
----------------
The OnOpen-Event of a form:

Private Sub Form_Open(Cancel As Integer)

Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset

With rst
.Source = "SELECT * FROM Test"
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.CursorLocation = adUseClient
.ActiveConnection = GetConnection(True)
.Open
End With

Set Me.Recordset = rst

Set rst = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim cnn As ADODB.Connection
Set cnn = Me.Recordset.ActiveConnection
cnn.Close
Set cnn = Nothing
End Sub

The table which i'm connecting has 4 columns with a primary key and a
trigger for the lastmodified column.

The error i'm getting is this:

"Key column information is insufficient or incorrect. Too many rows were
affected by update."

I believe the trigger caused this because upon inserting there are no
problems. Also the updated records are not directly visible on the form,
only if close and open it.

So what i would like is if the above mentioned codes could work, if not
please correct me.

 >> Stay informed about: updatable ado-recordset 
Back to top
Login to vote
Veign2

External


Since: Feb 04, 2004
Posts: 123



(Msg. 2) Posted: Tue Feb 22, 2005 4:12 pm
Post subject: Re: updatable ado-recordset [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

  >> Private Sub Form_Open

There is no Open event in VB. Is this an Access userform?

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
<a style='text-decoration: underline;' href="http://www.veign.com/vrc_main.asp" target="_blank">http://www.veign.com/vrc_main.asp</a>
--

"Jason" <jlewis RemoveThis @hotmail.com> wrote in message
news:uQvPskRGFHA.3792@TK2MSFTNGP10.phx.gbl...
 > 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 ADODB.Connection
 >
 > Public Function GetConnection(ByVal boolOpenIfClosed As Boolean) As
 > ADODB.Connection
 >
 > If mconn Is Nothing Then
 > Set mconn = New ADODB.Connection
 > With mconn
 > .Provider = "MSDataShape"
 > .ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA
 > SOURCE=local;DATABASE=test;UID=sa;PWD=;"
 > .CursorLocation = adUseServer
 > .Open
 > End With
 > End If
 > If mconn.State = adStateClosed Then
 > If boolOpenIfClosed Then
 > mconn.Open
 > End If
 > End If
 >
 > Set GetConnection = mconn
 >
 > End Function
 > ----------------
 > The OnOpen-Event of a form:
 >
 > Private Sub Form_Open(Cancel As Integer)
 >
 > Dim rst As ADODB.Recordset
 >
 > Set rst = New ADODB.Recordset
 >
 > With rst
 > .Source = "SELECT * FROM Test"
 > .LockType = adLockOptimistic
 > .CursorType = adOpenDynamic
 > .CursorLocation = adUseClient
 > .ActiveConnection = GetConnection(True)
 > .Open
 > End With
 >
 > Set Me.Recordset = rst
 >
 > Set rst = Nothing
 >
 > End Sub
 >
 > Private Sub Form_Unload(Cancel As Integer)
 > Dim cnn As ADODB.Connection
 > Set cnn = Me.Recordset.ActiveConnection
 > cnn.Close
 > Set cnn = Nothing
 > End Sub
 >
 > The table which i'm connecting has 4 columns with a primary key and a
 > trigger for the lastmodified column.
 >
 > The error i'm getting is this:
 >
 > "Key column information is insufficient or incorrect. Too many rows were
 > affected by update."
 >
 > I believe the trigger caused this because upon inserting there are no
 > problems. Also the updated records are not directly visible on the form,
 > only if close and open it.
 >
 > So what i would like is if the above mentioned codes could work, if not
 > please correct me.
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: updatable ado-recordset 
Back to top
Login to vote
Jason

External


Since: Feb 18, 2005
Posts: 7



(Msg. 3) Posted: Tue Feb 22, 2005 4:40 pm
Post subject: Re: updatable ado-recordset [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Veign,

Yes, it is. I thought this was a access forum.

"Veign" <NOSPAMinveign.DeleteThis@veign.com> schreef in bericht
news:O76$ZtRGFHA.3732@tk2msftngp13.phx.gbl...
   >>> Private Sub Form_Open
 >
 > There is no Open event in VB. Is this an Access userform?
 >
 > --
 > Chris Hanscom - Microsoft MVP (VB)
 > Veign's Resource Center
<font color=purple> > <a style='text-decoration: underline;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
 > --
 >
 > "Jason" <jlewis.DeleteThis@hotmail.com> wrote in message
 > news:uQvPskRGFHA.3792@TK2MSFTNGP10.phx.gbl...
  >> 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 ADODB.Connection
  >>
  >> Public Function GetConnection(ByVal boolOpenIfClosed As Boolean) As
  >> ADODB.Connection
  >>
  >> If mconn Is Nothing Then
  >> Set mconn = New ADODB.Connection
  >> With mconn
  >> .Provider = "MSDataShape"
  >> .ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA
  >> SOURCE=local;DATABASE=test;UID=sa;PWD=;"
  >> .CursorLocation = adUseServer
  >> .Open
  >> End With
  >> End If
  >> If mconn.State = adStateClosed Then
  >> If boolOpenIfClosed Then
  >> mconn.Open
  >> End If
  >> End If
  >>
  >> Set GetConnection = mconn
  >>
  >> End Function
  >> ----------------
  >> The OnOpen-Event of a form:
  >>
  >> Private Sub Form_Open(Cancel As Integer)
  >>
  >> Dim rst As ADODB.Recordset
  >>
  >> Set rst = New ADODB.Recordset
  >>
  >> With rst
  >> .Source = "SELECT * FROM Test"
  >> .LockType = adLockOptimistic
  >> .CursorType = adOpenDynamic
  >> .CursorLocation = adUseClient
  >> .ActiveConnection = GetConnection(True)
  >> .Open
  >> End With
  >>
  >> Set Me.Recordset = rst
  >>
  >> Set rst = Nothing
  >>
  >> End Sub
  >>
  >> Private Sub Form_Unload(Cancel As Integer)
  >> Dim cnn As ADODB.Connection
  >> Set cnn = Me.Recordset.ActiveConnection
  >> cnn.Close
  >> Set cnn = Nothing
  >> End Sub
  >>
  >> The table which i'm connecting has 4 columns with a primary key and a
  >> trigger for the lastmodified column.
  >>
  >> The error i'm getting is this:
  >>
  >> "Key column information is insufficient or incorrect. Too many rows were
  >> affected by update."
  >>
  >> I believe the trigger caused this because upon inserting there are no
  >> problems. Also the updated records are not directly visible on the form,
  >> only if close and open it.
  >>
  >> So what i would like is if the above mentioned codes could work, if not
  >> please correct me.
  >>
  >>
 >
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: updatable ado-recordset 
Back to top
Login to vote
Veign2

External


Since: Feb 04, 2004
Posts: 123



(Msg. 4) Posted: Tue Feb 22, 2005 4:40 pm
Post subject: Re: updatable ado-recordset [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

No...This is for ADO. Try one of the Access newsgroups and you will
probably get more responses.

Good Luck!

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
<a style='text-decoration: underline;' href="http://www.veign.com/vrc_main.asp" target="_blank">http://www.veign.com/vrc_main.asp</a>
--

"Jason" <jlewis RemoveThis @hotmail.com> wrote in message
news:%23Vq6BuRGFHA.1392@tk2msftngp13.phx.gbl...
 > Hi Veign,
 >
 > Yes, it is. I thought this was a access forum.
 >
 > "Veign" <NOSPAMinveign RemoveThis @veign.com> schreef in bericht
 > news:O76$ZtRGFHA.3732@tk2msftngp13.phx.gbl...
   > >>> Private Sub Form_Open
  > >
  > > There is no Open event in VB. Is this an Access userform?
  > >
  > > --
  > > Chris Hanscom - Microsoft MVP (VB)
  > > Veign's Resource Center
<font color=green>  > > <a style='text-decoration: underline;' href="http://www.veign.com/vrc_main.asp</font" target="_blank">http://www.veign.com/vrc_main.asp</font</a>>
  > > --
  > >
  > > "Jason" <jlewis RemoveThis @hotmail.com> wrote in message
  > > news:uQvPskRGFHA.3792@TK2MSFTNGP10.phx.gbl...
   > >> 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 ADODB.Connection
   > >>
   > >> Public Function GetConnection(ByVal boolOpenIfClosed As Boolean) As
   > >> ADODB.Connection
   > >>
   > >> If mconn Is Nothing Then
   > >> Set mconn = New ADODB.Connection
   > >> With mconn
   > >> .Provider = "MSDataShape"
   > >> .ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA
   > >> SOURCE=local;DATABASE=test;UID=sa;PWD=;"
   > >> .CursorLocation = adUseServer
   > >> .Open
   > >> End With
   > >> End If
   > >> If mconn.State = adStateClosed Then
   > >> If boolOpenIfClosed Then
   > >> mconn.Open
   > >> End If
   > >> End If
   > >>
   > >> Set GetConnection = mconn
   > >>
   > >> End Function
   > >> ----------------
   > >> The OnOpen-Event of a form:
   > >>
   > >> Private Sub Form_Open(Cancel As Integer)
   > >>
   > >> Dim rst As ADODB.Recordset
   > >>
   > >> Set rst = New ADODB.Recordset
   > >>
   > >> With rst
   > >> .Source = "SELECT * FROM Test"
   > >> .LockType = adLockOptimistic
   > >> .CursorType = adOpenDynamic
   > >> .CursorLocation = adUseClient
   > >> .ActiveConnection = GetConnection(True)
   > >> .Open
   > >> End With
   > >>
   > >> Set Me.Recordset = rst
   > >>
   > >> Set rst = Nothing
   > >>
   > >> End Sub
   > >>
   > >> Private Sub Form_Unload(Cancel As Integer)
   > >> Dim cnn As ADODB.Connection
   > >> Set cnn = Me.Recordset.ActiveConnection
   > >> cnn.Close
   > >> Set cnn = Nothing
   > >> End Sub
   > >>
   > >> The table which i'm connecting has 4 columns with a primary key and a
   > >> trigger for the lastmodified column.
   > >>
   > >> The error i'm getting is this:
   > >>
   > >> "Key column information is insufficient or incorrect. Too many rows
were
   > >> affected by update."
   > >>
   > >> I believe the trigger caused this because upon inserting there are no
   > >> problems. Also the updated records are not directly visible on the
form,
   > >> only if close and open it.
   > >>
   > >> So what i would like is if the above mentioned codes could work, if not
   > >> please correct me.
   > >>
   > >>
  > >
  > >
 >
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: updatable ado-recordset 
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 ]