Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-29-2005, 11:45 AM   PM User | #1
kafsar
New to the CF scene

 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kafsar is an unknown quantity at this point
Question Select , Count(*) in MySQL

I write the following code in vb6 its work fine for Access and MSSQL but not work with MySQL, RecordCount return -1 always kindly help me..


Dim mms As ADODB.Connection

Set mms = New ADODB.Connection
mms.ConnectionString = "DRIVER = MYSQL ODBC 3.51 Driver;SERVER=10.48.60.183;DATABASE=mms;UID=kma;pwd=abcd
mms.Open

Set rstIWOrder = New ADODB.Recordset

SelectString = "select * from IWOrder where WON ='"
SelectString = SelectString + txtIWO.Text + "'"
rstIWOrder.Open SelectString, mms, adOpenStatic, adLockReadOnly

If rstIWOrder.RecordCount = 0 Then
MsgBox "Internal Work Order not Found in Database"

else

or

SelectString = "select count(*) from IWOrder where WON ='"
SelectString = SelectString + txtIWO.Text + "'"
rstIWOrder.Open SelectString, mms, adOpenStatic, adLockReadOnly
kafsar is offline   Reply With Quote
Old 01-29-2005, 01:06 PM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
welcome here!

RecordCount is a recordset-function so it has nothing to do with sql or the db-format.
the reason why you get a -1 value is because of your cursortype.

just use the

SELECT COUNT(*) as reccount FROM ...

and then get the value with
rstIWOrder.Fields("reccount").Value
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:52 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.