473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ADODB & Queries

On a form, I have a command button that has the following event onClick:

Private Sub Command0_Click()
Dim rslt As ADODB.Recordset, sqlstr As String
sqlstr = "SELECT Table1.id, Table1.name, Table1.value FROM Table1
WHERE Table1.name like '%" & Text1.Value & "%'"
Set rslt = New ADODB.Recordset
Set rslt.ActiveConnection = CurrentProject.Connection
rslt.Open sqlstr
MsgBox rslt.RecordCount
End Sub

No matter what I enter into the Text1 box (on the form), I always get a
RecordCount of -1.

So, I created a query by selecting SQL view and pasting in:

SELECT Table1.id, Table1.name, Table1.value FROM Table1 WHERE
Table1.name like '%jo%'

When I run the query, I get 6 rows returned.

What (likely obvious) detail am I missing here? I threw in a MsgBox
sqlstr to be sure that the query looks exactly as it should...

--
Justin Koivisto - ju****@koivi.com
http://koivi.com
Nov 13 '05 #1
5 1596
By default the cursor type of an ADO recordset is adOpenForwardOnly.
This will not allow the return of RecordCount. Set the cursor type to
AdOpenKeySet or AdOpenStatic and RecordCount should be accurate.
You may also want/need to consider CursorLocation and LockType,
depending on what you want to do.

Nov 13 '05 #2
ly******@yahoo.ca wrote:
By default the cursor type of an ADO recordset is adOpenForwardOnly.
This will not allow the return of RecordCount. Set the cursor type to
AdOpenKeySet or AdOpenStatic and RecordCount should be accurate.
You may also want/need to consider CursorLocation and LockType,
depending on what you want to do.


Lyle, what is the ADO openrecordsettype equivalent of the DAO
dbOpenSnapshot?

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #3
For an old article which discusses this see:
http://msdn.microsoft.com/library/de...ml/ima0501.asp

Nov 13 '05 #4
ly******@yahoo.ca wrote:
For an old article which discusses this see:
http://msdn.microsoft.com/library/de...ml/ima0501.asp


Thanks, appreciate it, that will help me.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #5
ly******@yahoo.ca wrote:
By default the cursor type of an ADO recordset is adOpenForwardOnly.
This will not allow the return of RecordCount. Set the cursor type to
AdOpenKeySet or AdOpenStatic and RecordCount should be accurate.
You may also want/need to consider CursorLocation and LockType,
depending on what you want to do.


Thanks, that is exactly what I needed.

--
Justin Koivisto - ju****@koivi.com
http://koivi.com
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcin Grzębski | last post by:
Hi All! I can't find any good equivalent of VB6 params from samples which should be used as a 2nd and 3rd parameter in method: Connection.OpenSchema(ADODB.SchemaEnum schema , object criteria...
3
by: google | last post by:
I'm using ADODB to connect to an Access database from VB6. I'm running a query that's returning strange results- the following query returns different results in VB & Access: SELECT * FROM...
4
by: R. Rajesh Jeba Anbiah | last post by:
If you're working in PHP 5 and used APD, phpDocumentor, PHPMailer & ADODB, you might be knowing that these projects are not maintained and the old codes are throwing bunch of errors in higher error...
0
by: CountDraculla | last post by:
Fixing Multiple Database bug in adoDB popular data access layer for php, adoDB can support multiple databases from different provider at time, but not from same provider. what I mean is if you...
7
by: trpost | last post by:
I just started using the php adodb library for my Oracle transactions, but am running into a problem when there are 2 simultaneous requests going on at the same time. The nature of the php app...
0
by: dmckenna | last post by:
I've been tasked to upgrade an old system and there's many different versions of VB code that uses MDAC to talk to MSSql. Do you know what the difference is between the two code versions? Is there...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
6
by: simon.robin.jackson | last post by:
Ok. I need to develop a macro/vba code to do the following. There are at least 300 corrections and its expected for this to happen a lot more in the future. Therefore id like a nice...
6
by: avcitamer | last post by:
We upgraded our system and problem below occured, pleas help me... Windows 2003 server SP1 When I set a decimal DB field value to "123,32" (using ADODB.recordset ) updated value was ok (123.32)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.