473,804 Members | 2,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Classes by Recordset

Let me see if I can explain this correctly.

In VB.NET, I want to call classes based on a recordset I get back from
a SQL Server database.

Basically, I have a value sending in a table called
cls.CallFunctio n(strParameter) .

In VB.NET cls.CallFunctio n is a class and a function in my code.

How do I convert my recordset value (cls.CallFuncti on (strParameter))
into a string value that will actually call the function.

Gosh, I hope that makes sense, and I didn't sound like a complete
idiot

Please respond back to this post :)

Thanks!
Nov 21 '05 #1
1 1686
here's the idea:
(Note: watch for typos and syntax - I'm directly typing this in this message
so you'll have to double check syntax, etc etc)

first - trim the string to get the class name, method name and method
parameter(s) seperated out.
Dim str As String = "cls.CallFuncti on(strParameter )"
Dim ClassName As String = str.SubString(1 , str.IndexOf("." )-1)
Dim MethodName As String = _
str.SubString(s tr.IndexOf(".") +1, str.IndexOf("(" ) - str.IndexOf("." ))
Dim Parameter As String = _
str.SubString(s tr.IndexOf("(") +1, str.Index(")") - str.Index("("))
(you'll have to do a little more work if you have more than one parameter)

Then use Type.GetType( ) method to get the type object for your class (read
up the documentation on Type.GetType( ) to make sure you get it right -
there are several rules on how to pass in the class name; for instance, you
need to pass in your application name, namespace name, etc etc)
Something like:

Dim myType As Type = Type.GetType(my AppName & myNameSpace & ClassName)

Then use the InvokeMember function of the type class to execute the method.
Something like:

Dim args( ) As Object = {strParameter}
myType.InvokeMe mber("CallFunct ion", BindingFlags.Pu blic Or _
BindingFlags.In vokeMethod, Nothing, Nothing, args)
(make sure you get the BindingFlags right otherwise it'll blowup here.
lookup the various values for BindingFlags and use the ones that match the
criteria for your method)

Well - thats just about the idea on how to do this.

hope that helps..
Imran
..
"Amanda" <de*****@hotmai l.com> wrote in message
news:55******** *************** ***@posting.goo gle.com...
Let me see if I can explain this correctly.

In VB.NET, I want to call classes based on a recordset I get back from
a SQL Server database.

Basically, I have a value sending in a table called
cls.CallFunctio n(strParameter) .

In VB.NET cls.CallFunctio n is a class and a function in my code.

How do I convert my recordset value (cls.CallFuncti on (strParameter))
into a string value that will actually call the function.

Gosh, I hope that makes sense, and I didn't sound like a complete
idiot

Please respond back to this post :)

Thanks!

Nov 21 '05 #2

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

Similar topics

6
6904
by: dw | last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." I've run the same stored procedure with the same exact list of arguments in Query Analyser in SQL Server, and it works. The page has the adovbs constants. Note that uspGetProperties is a stored procedure in SQL...
0
1905
by: Johan Lachonius | last post by:
Hi, I'm using a "classic" asp-page and a .net-component which I want to call passing a Recordset as a parameter. I have a reference to ADODB in the .net component which should supply a COM rapper for a Recordset. In the .net component code looks like: using ADODB: public void MyFunction( Recordset rs )
4
5724
by: Gerry Abbott | last post by:
Hi all. I wish to call a recordset from a function. Ive tried the following approach, -------------------------------------------------------- Function PassRS() As Recordset Dim db As Database Dim rs As Recordset Dim myQdf As QueryDef
5
2642
by: Zlatko Matiæ | last post by:
Hello. How can I call some functions on MSDE when working in .mdb ? Especially in-line functions which are similar to stored procedures. How can I use MSDE in-line functions as recordsource for .mdb forms ? Can I call in-line functions using ADO ? I tried, but it seems that only stored procedures are allowed (adCmdStoredProc).... Thanks.
30
2292
by: Tim Marshall | last post by:
Here's the scenario, A2003, Jet back end, illustrated with some cut down code at the end of the post: A proc dims a snapshot recordset (dim rst as Dao.recordset) and opens it. There are several nested do loops, going through the records in rst using .movenext. At one point in one of the loops, we'll say the rst is at record "a". Now, another subprocedure is called, passing rst to it. In the subprocedure, the recordset goes through a...
4
6725
by: Jack | last post by:
Hi, I am trying to run an example code from a book. However I am getting the following error message: Number: -2147217900 Description: Syntax error or access violation Source: Microsoft OLE DB Provider for SQL Server SQLState: 42000
0
924
by: mosscliffe | last post by:
Can anyone recommend any article which differentiates, between all the sqlClient classes. As I am getting confused as to which is the best approach, bearing in mind my desire to have efficient access and avoid unnecessary trips to the server . I suppose my requirements are an 'updateable' RecordSet and a 'read only' RecordSet, but the SQLReader seems as though it will not work in a paging environment, as it is read forward only. If...
0
1501
by: klove1209 | last post by:
Good afternoon. I need assistance with calling a function on the back end, that takes paremeters for a stored procedure. Then, that function returns the recordset back to the main DB. Below is the code for the procedures on the back and, and what I have so far on the front end. **This function calls the stored query, with given parameters, and returns the recodset** Public Function RSFromParameterQuery(strMonthYear As Date, strCase As...
0
1147
by: klove1209 | last post by:
Good afternoon. I need assistance with calling a function on the back end, that takes paremeters for a stored procedure. Then, that function returns the recordset back to the main DB. Below is the code for the procedures on the back and, and what I have so far on the front end. **This function calls the stored query, with given parameters, and returns the recodset** Public Function RSFromParameterQuery(strMonthYear As Date, strCase As...
0
9706
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10569
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10315
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.