Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > recordsets?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2001, 06:41 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Question recordsets?


hi folks, i'm trying to update a recordset depending on a condition, here's my code

Dim rsSoumission As Recordset
Set rsSoumission = New Recordset
rsSoumission.LockType = adLockOptimistic
rsSoumission.CursorType = adOpenDynamic
Set rsSoumission = frmMenuPrincipale.cn.Execute("select * from soumission where nosoumission = '" & tempSoum & "' and norevision='" & tempRev & "'")
With rsSoumission
If newRev Then .AddNew
!noSoumission = tempSoum
!noRevision = tempRev
...
.update
set rssoumission = nothing

but now i get the error message saying that the provider cannot support....blah blah blah
I'll be among the best soon, very soon!!!<P ID="edit"><FONT class="small"><EM>Edited by Laurent on 08/03/01 07:43 AM.</EM></FONT></P>
__________________
Still tons to learn!
Reply With Quote
  #2  
Old 08-03-2001, 06:50 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

Even though you are requesting a Dynamic cursor, the provider you are using may not support Dynamic. When it doesn't support a type it changes to a type it does support. I am guessing it is changing to a type that won't allow adding a new record. You can check this with this line of code.
<pre>
If rsSoumission.Supports(adAddNew) Then Debug.Print "Yes" Else Debug.Print "No"
</pre>
This is just a guess because otherwise the code looks good to me.

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
  #3  
Old 08-03-2001, 06:58 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

basicly what i want it to do is create a new record if newrev (new revision) equal true, but if it doesn't than cange the existing record. do i have the correct syntax for this?

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #4  
Old 08-03-2001, 07:10 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

I think it is ok. Will it update an existing record? If the only problem is adding a new record then check my previous post. Otherwise there is a bigger problem.

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 08-03-2001, 07:15 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

i was modifying it this morning, it was adding correctly any new records, but i can,t get it to modify an existing one? i just don't get it!

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #6  
Old 08-03-2001, 07:22 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

Do you get an error? Or does it act like it is changing but when you look again it hasn't changed it.

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
  #7  
Old 08-03-2001, 07:57 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

THE RESQUESTED OPERATION CANNOT BE SUPPORTED BY THE PROVIDER is my error message?

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #8  
Old 08-03-2001, 08:10 AM
jcd
Guest
 
Posts: n/a
Default Re: recordsets?

I dont know if this will make a difference but have you tried this syntax [recordset].open [query statement], [activeconection], [cursor], [locktype]...I dont know if this will help the error but, it doesnt hurt to try.
Regards
jcd

Reply With Quote
  #9  
Old 08-03-2001, 08:37 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

This might seem a little strange but try this.
<pre>
...
If Not newRev Then rsSoumission.Move 0
.Update
</pre>

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
  #10  
Old 08-03-2001, 08:42 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

i tried all in one line also but the same error occurs

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #11  
Old 08-03-2001, 08:42 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

i also tried to move it to 0 but no succes!! : (

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #12  
Old 08-03-2001, 09:05 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

I am sorry I missed the Error message in your first post.
Please add this line right before the .Update
<pre>
If rsSoumission.Supports(adUpdate) Then MsgBox "Yes" Else MsgBox "No"
</pre>
Run again and see if it says Yes or No. Does it say Yes for a new addition and No for an update?

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
  #13  
Old 08-03-2001, 10:34 AM
Laurent Laurent is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Apr 2001
Location: canada, quebec
Posts: 1,334
Default Re: recordsets?

is says false to both? i don't get it i'm using the same function for the past 3 months with addnew and it says it doesn't support it...

I'll be among the best soon, very soon!!!
__________________
Still tons to learn!
Reply With Quote
  #14  
Old 08-03-2001, 11:22 AM
ANUNEZ
Guest
 
Posts: n/a
Default Re: recordsets?

Hi.
I bet that you are using micosoft jet for this.
This happens because the execute method returns a readonly recordset for that provider. Try using the open method:

set rst = new adodb.recordset

rst.Open "SELECT * FROM table1", cnn, adOpenDynamic, adLockOptimistic

instead of execute.

I hope this help.

Reply With Quote
  #15  
Old 08-04-2001, 02:47 PM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: recordsets?

Laurent, I'm sorry I couldn't get back to you sooner but it
looks like ANUNEZ figured it out. I hope you followed his
advice because he is right. When you created a new
recordset and set its parameters
<pre>
Set rsSoumission = New Recordset
rsSoumission.LockType = adLockOptimistic
rsSoumission.CursorType = adOpenDynamic
</pre>
Then it was right. But as soon as you did
<pre>
Set rsSoumission = frmMenuPrincipale.cn.Execute("select * from soumission where nosoumission = '" & _
tempSoum & "' and norevision='" & tempRev & "'")
</pre>
You wiped out the recordset you created to begin with and
replaced it with another one created by the Connection
object. As ANUNEZ pointed out, the default would not allow
changes. It really shouldn't have allowed additions either
but somehow that still worked. By using the .Open method
and passing all the parameters, the Connection object could
make sure the recordset was initialized the way you needed
it.

There are a couple of small changes I would make to ANUNEZ's
Open statement.
<pre>
.Open "SELECT * FROM table1", cnn, adOpenKeyset, adLockOptimistic, adCmdText
</pre>
You can't get a Dynamic cursor even if you ask for it. It
changes it to Keyset. But, it doesn't give you all the features
of a Keyset like the Bookmark and RecordCount. If you
specify Keyset then you do get them. Also telling the
Connection object that the source is an SQL statement with the adCmdText option, will speed it up a little.

I think therefore I am... sometimes right. [img]images/icons/wink.gif[/img]
__________________
Posting Guidelines
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->