473,387 Members | 1,590 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,387 software developers and data experts.

Calling Function on Back-end

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**
Expand|Select|Wrap|Line Numbers
  1. Public Function RSFromParameterQuery(strMonthYear As Date, strCase As Integer) As ADODB.Recordset
  2.  
  3.    Dim prm As ADODB.Parameter
  4.    Dim prm2 As ADODB.Parameter
  5.    Dim cmd As ADODB.Command
  6.    Dim rst As ADODB.Recordset
  7.  
  8.    Set cmd = New ADODB.Command
  9.    Set cmd.ActiveConnection = CurrentProject.Connection
  10.  
  11.    cmd.CommandText = "qryMData"
  12.    cmd.CommandType = adCmdStoredProc
  13.  
  14.  
  15. Set prm = cmd.CreateParameter("prmmonthyear", adDate, adParamInput, Len(strMonthYear))
  16. Set prm2 = cmd.CreateParameter("prmcase", adInteger, adParamInput, Len(strCase))
  17.  
  18.  
  19.    prm.value = strMonthYear
  20.    prm2.value = strCase
  21.  
  22.    cmd.Parameters.Append prm
  23.    cmd.Parameters.Append prm2
  24.  
  25.    Set rst = New ADODB.Recordset
  26.  
  27.    rst.Open cmd
  28.  
  29.     Set RSFromParameterQuery = rst
  30.  
  31. End Function
  32.  
  33. **This is the function that i have written for the front-end. It opens the datasource, but what next?**
  34.  
  35. Public Function testprocedure2()
  36.  
  37. Const adOpenOtatic = 3
  38. Const adUseClient = 3
  39. Const adLockBatchOptimistic = 4
  40.  
  41. Dim cmd As New ADODB.Command
  42.  
  43.  'Open a connection
  44.     Set oConn = CreateObject("ADODB.Connection")
  45.   oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  46.                         "Persist Security Info=False;" & _
  47.                         "Data Source=\\---------"
  48.  
  49.   'Create the Recordset object
  50.   Set rst = CreateObject("ADODB.Recordset")
  51.   rst.CursorLocation = adUseClient
  52.  
  53. Set rst.ActiveConnection = oConn
  54.  
  55. 'returns function as recordset
  56. Set rst = RSFromParameterQuery("3/1/2007", "2") **This works when the data is in the same database, but not when the database is split
  57.  
  58.    Do Until rst.EOF
  59.       Debug.Print rst(0), rst(1), rst(2)
  60.       rst.MoveNext
  61.    Loop
  62.  
  63. End Function
Jun 4 '07 #1
0 1463

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

Similar topics

7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
0
by: Richard Mathis | last post by:
My problem is rather complicated (for me), so I'm going to post my problem here as well as what I've done so far to solve my problem. Any assistance would be appreciated. I originally posted this...
5
by: Dave | last post by:
does calling a regular function cost any cpu time? In other words, is it faster to write the code of two functions into main(), or is it the exact same thing as calling two functions. I know its...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
11
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: sumanthsclsdc | last post by:
Hello friends, I have a problem, I implemented a class which uses tkinter and displays the window as required, the class will create a window with listbox and inserts some items into it, I...
2
by: eholz1 | last post by:
Hello PHP Group, I have a php page that calls another php page to load a image from a database (mysql) in to the calling page. It works like this: first_view.php has <img src="image.php?img=5"...
5
by: Stinky Pete | last post by:
Hi (again) ;-) I'm still very much at the bottom of a steep learning curve with VB, so any and all help is always appreciated. I've found some code to generate the user names who have logged...
47
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
9
by: mrcheeky | last post by:
Hi, I'm stuck, but it's almost working! From a html page, my javascript calls a server-side php script. The php reads a value from a server-side .txt file and passes it back as a javascript...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...
0
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...

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.