473,582 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid use of property, returning recordset object from a function

1 New Member
Hi,

I am running a simple select query on a connection with mysql database. On returning recordset froma function object I get an "Invalid use of property" error. I have no idea why its doing that.

I have tried the query in MySql and it works fine and gives the expected result.


Dim ConnectionStrin g As String
Set conn = New ADODB.Connectio n
ConnectionStrin g = "Driver={My SQL ODBC 3.51 Driver};Server= localhost;Port= 3306;Database=D b1;User=rr;Pass word=;Option=3; "
conn.Connection String = ConnectionStrin g
conn.CursorLoca tion = adUseClient
conn.Open

Public Function getUser() As ADODB.Recordset
Dim rs As ADODB.Recordset

Set rs = conn.Execute("S ELECT user_id, user From users ORDER BY rand( ) LIMIT 1")
'Set rs = New ADODB.Record
'rs.Open "SELECT user_id, user From users ORDER BY rand( ) LIMIT 1", conn
'rs.MoveFirst

getUserAgent = rs '''''''''''''(e rror on this line)

End Function



Anyone got any ideas?



Thanks

Zeeshan
May 22 '07 #1
1 3315
danp129
323 Recognized Expert Contributor
'Function getUser' should be changed to 'Function getUserAgent' or getUserAgent should be changed to getUser.. would be where I would start..
May 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6123
by: Jagdip Singh Ajimal | last post by:
I have the following code Private dataEnviron As dataEnv Private DBconn As Connection Private Sub Class_Initialize() Set dataEnviron = New dataEnv Set DBconn = dataEnviron.OracleConn DBconn.Open End Sub
2
4619
by: sean | last post by:
HI, I would like to know if I can some set a variable to return a single value from a function using the set command. Is this possible? Thanks in advance for your answer Sean
4
4966
by: Navin Kulshreshtha | last post by:
Hi folks, I'm opening a recordset with a SQL statement and then trying to use the .RecordCount property to count the number of rows in the recordset. For some reason, it is always returning -1. Here's the code (I have left out the details for the connection string): ------------------- strSQL = "SELECT * from orders" strConnect = Set...
1
3138
by: Robin Hammond | last post by:
Can anybody tell me why a) when running a stored proc from an asp page to return a recordset the command succeeds if the sp queries an existing table directly, but b) if the stored proc populates results into a different table, temporary table, global temp table, or table variable, then queries one of these, the asp page reports that the...
16
25401
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
6
6528
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
1
8419
by: Andy G | last post by:
I've been getting this error all day. Could someone please look at my stored procedure and the code. I have a form that grabs and email address the user types in, calls a stored procedure with an input parameter and an output parameter, compared the email to a table and matches an ID in another table to grab the Username. thanks for any...
6
3203
by: Bob Darlington | last post by:
I want to use the caption property for fields in a recordset as a condition in a loop. That is, I only want to consider those fields which have captions: For each fld in RecordsetName.Fields If fld.Properties("Caption") <"" then do something The problem is that all fields are included, even those with no caption set. I've tried...
3
9578
by: Jon L | last post by:
Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the language. I'm using the Microsoft.XMLDOM object in an ASP page to read an incoming XML post request and respond to it. Although the XMLDOM object verifies the XML at a basic level, I want to make...
0
7886
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7809
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8183
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.