Dear All,
How can I show the resultrecords of a SP.
I can be done by doubleclick the SPname?
But how to do it by code.
I want the following interface
In my form the user
1 selects a SP (combobox showing a userfrinly name)
2 adds the related parameters
3 and then click the show result-button
but the .execute command doen't show teh records.
I want the same output as you have doublclicking the SPname in the
objectwindow.
Thanks,
Filip 13 4848
Hi Filip,
I will assume you are using an Access ADP. In the ADP you can create a
form and base the Form's RecordSource on the SP. Just add the columns
that the sp returns to the Form from the field list in the Form
designer. Place the form in datasheet view. You can make it a subform
and show it from a mainform.
If you are not using an ADP but an mdb, then you use ADO to generate a
recordset. Write that recordset to a table and base a form on that
table.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
DoCmd.OpenStore dProcedure "SpGetFFDBAAcco unts"
There are two optional parameters:
AcView -> acViewNormal || acViewPivotChar t || acViewPivotTabl e ||
acViewPreview
and
DataMode -> acEdit || acAdd || AcReadOnly.
I have not used these. Datamode may be useful.
DoCmd.OpenStore dProcedure "Spxxxxx" asks the parameters again.
I would like to open the SP without asking the parametervalues again, just
pick them from the formcontrols.
In a table I store the parameters related to each SP with a usersfrindly
question.
I was hoping to be able to add new SPs without changing the interface,
without adding a form for each new SP
"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . DoCmd.OpenStore dProcedure "SpGetFFDBAAcco unts"
There are two optional parameters:
AcView -> acViewNormal || acViewPivotChar t || acViewPivotTabl e || acViewPreview and DataMode -> acEdit || acAdd || AcReadOnly.
I have not used these. Datamode may be useful.
I was hoping to be able to add new SPs without changing the interface,
without adding a form for each new SP and still provide the parametervaleus
in the forms controls.
"Rich P" <rp*****@aol.co m> wrote in message
news:5z******** *******@news.us west.net... Hi Filip,
I will assume you are using an Access ADP. In the ADP you can create a form and base the Form's RecordSource on the SP. Just add the columns that the sp returns to the Form from the field list in the Form designer. Place the form in datasheet view. You can make it a subform and show it from a mainform.
If you are not using an ADP but an mdb, then you use ADO to generate a recordset. Write that recordset to a table and base a form on that table.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Filips Benoit wrote: DoCmd.OpenStore dProcedure "Spxxxxx" asks the parameters again.
Sub OpenStoredProce dure(ProcedureN ame, [View As AcView = acViewNormal],
[DataMode As AcOpenDataMode = acEdit])
Member of Access.DoCmd
View and DataMode are optional parameters. A Call to the Sub should not
ask for these parameters, and will not in Access 2003. Look at the
Intellisense; if the parameters are in [square brackets] they are
optional and not required.
Regardless, you should be able to use
DoCmd.OpenStore dProcedure "Spxxxxx", acViewNormal, acEdit, or whataver
parameters you want.
If you are still having problems tell us the version of Access. I've
assumed you are using an ADP.
Its about the SP-parameters not the parameters of the Sub
(DoCmd.OpenStor edProcedure).
I want to input the SP-parameters in my form and check the datatype befor
opening the SP.
BUT with DoCmd.OpenStore dProcedure "Spxxxxx" I can't provide the
SP-parameters to the SP and it ask them again !
I want the following interface
A form where the user
1 selects a SP (combobox showing a userfrinly SP-names stored in a table
CUSTOM_QUERY)
2 adds the related parameters ( stored in another
tableCUSTOM_QUE RY_PARAMETERS)
3 Checking the parametervalues befor opening the SP
4 Opening the SP as table and providing the SP-parameters by code.
1,2 and 3 is no problem but I want to do 4 only with code without creating a
new form for each SP so the access-inteface should not be edited for each
new SP !!!
Thanks,
Filip
"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:11******** *************@i 39g2000cwa.goog legroups.com... Filips Benoit wrote: DoCmd.OpenStore dProcedure "Spxxxxx" asks the parameters again.
Sub OpenStoredProce dure(ProcedureN ame, [View As AcView = acViewNormal], [DataMode As AcOpenDataMode = acEdit]) Member of Access.DoCmd
View and DataMode are optional parameters. A Call to the Sub should not ask for these parameters, and will not in Access 2003. Look at the Intellisense; if the parameters are in [square brackets] they are optional and not required.
Regardless, you should be able to use
DoCmd.OpenStore dProcedure "Spxxxxx", acViewNormal, acEdit, or whataver parameters you want.
If you are still having problems tell us the version of Access. I've assumed you are using an ADP.
I think I understand ... Spxxxx requires input parameters? right? I'll
think on that ...
right
Thanks for following me !
Filip
"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:11******** **************@ j73g2000cwa.goo glegroups.com.. . I think I understand ... Spxxxx requires input parameters? right? I'll think on that ...
This works here but it is TRÈS ugly! I do not offer it as anything
exemplary.
SpGetLoanIntere st has one input parameter; @AnnualInterest defaulting
to 1.08 and this is changed to 1.125 for the "running". It does not
matter if the Paramaters have default values. The entire script of the
Procedure is appended in hopes that it may help you or anyone
understand.
**** begin code ****
Option Compare Database
Option Explicit
Sub temp()
Dim TSQL As String
On Error Resume Next
CurrentProject. Connection.Exec ute "DROP Procedure TempProcedure"
On Error GoTo 0
TSQL = GetSQLStringFro mSP("SpGetLoanI nterest")
TSQL = Replace(TSQL, "@AnnualRat e", "1.125")
CurrentProject. Connection.Exec ute "CREATE PROCEDURE TempProcedure
AS " & TSQL
DoCmd.RunComman d acCmdViewStored Procedures
Application.Ref reshDatabaseWin dow
DoCmd.OpenStore dProcedure "TempProced ure"
CurrentProject. Connection.Exec ute "DROP Procedure TempProcedure"
End Sub
Public Function GetSpTSQL(ByVal SpName As String) As String
Dim TSQL As String
TSQL = "SELECT text from SysComments c JOIN SysObjects o ON c.ID =
o.ID WHERE o.Name = '" & SpName & "'"
GetSpTSQL =
Trim(CurrentPro ject.Connection .Execute(TSQL). Collect(0))
End Function
Public Function GetSQLStringFro mSP(ByVal SpName As String) As String
Dim spTSQL As String
Dim Position As String
spTSQL = GetSpTSQL(SpNam e)
Position = InStr(spTSQL, "AS") + 2
GetSQLStringFro mSP = Mid$(spTSQL, Position)
GetSQLStringFro mSP = Replace(GetSQLS tringFromSP, "RETURN", "")
GetSQLStringFro mSP = Trim(GetSQLStri ngFromSP)
End Function
**** end code ****
**** T-SQL in spGetLoanIntere st ****
ALTER PROCEDURE spGetLoanIntere st
@AnnualRate float=1.08
AS
DECLARE @Balance smallmoney
DECLARE @DailyRate float
DECLARE @Date smalldatetime
DECLARE @Days int
DECLARE @DaysInYear float
DECLARE @DaysInYearReci procal float
DECLARE @Interest smallmoney
DECLARE @Period float
DECLARE @PreviousDate smalldatetime
EXECUTE spLoanInterest
SET @DaysInYear = 365
SET @Period = 1
SET @DaysinYearReci procal=(@Period/@DaysInYear)
SET @DailyRate = POWER(@AnnualRa te,@DaysInYearR eciprocal)
SELECT @Date = Max([Date]) FROM Loan
SET @Days = DATEDIFF(dayofy ear, @Date, GETDATE())
SELECT Top 1 @Balance = Balance FROM Loan Order By [Date] desc, ID
desc
SET @Interest = POWER(@DailyRat e, @Days) * @Balance - @Balance
SET @Balance = @Balance + @Interest
SELECT [Date], [Amount], [Note], [Interest], [Balance] FROM [Loan]
UNION
SELECT
GETDATE() as DATE ,
0 AS Amount,
'Current Balance' AS Note,
@Interest AS Interest,
@Balance AS Balance
ORDER BY Date
RETURN
**** end T-SQL ****
I can't remember what this Sproc actually does; I just chose it as
something to work on. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Holden |
last post by:
Has anyone, with any driver whatsoever, managed to retrieve output
parameters from a SQL Server stored procedure? I've just been rather
embarrassed to find out it's not as easy as it might seem, and people
are saying bad things about Python as a result :-(
mx.ODBC, which I regard as a highly-capable module, does not support the
callproc() API, and suggests use of the ODBC call format. It has caveats
in (some of) the documentation...
|
by: Begoña |
last post by:
in my java application I've made a call to this stored procedure
CREATE procedure pruebaICM
@pANI varchar(20),
@pTABLA varchar(20),
@pInsert varchar(500),
@pUpdate varchar(1000),
@pFLAG varchar(1),
@pResultado int OUTPUT
|
by: Jay Chan |
last post by:
I am trying to use a command line program to run a stored procedure
that generates output in a comma-delimitted format. Somehow, ISQL or
OSQL always wrap the lines at 256 characters. I believe this has
something to do with the column width switch (-w). But enlarging the
column width to 800 characters max still doesn't help. The following
is a stored procedure that is essentially doing what my stored
procedure is doing:
create procedure...
|
by: Bruce |
last post by:
Since DBlib is no longer the suggested method for connecting back to
sql server from an Extended Stored Procedure, has anyone built any
extended stored procedures that use other connection methods like
OLEDB? Has anyone seen links to any sample extended stored procedures
that use something other than db-lib? In particular I am interested
in something that connects back to the database as the user who
invoked the extended stored...
|
by: Steven |
last post by:
I'm calling a stored procedure which has an output parameter of type int.
Once the stored procedure is executed, I want to check the value of the
parameter in case it is null. However, when the a null value is returned I
don't seem to be able to detect it.
Any help would be greatly appreciated.
C# code is as follows:
SqlCommand cmd = new SqlCommand("sp_GetApplicationID", conn);
| |
by: Yusuf INCEKARA |
last post by:
I have a stored procedure :
CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR
|
by: Christopher Weaver |
last post by:
I'm having trouble accessing the value of an output parameter of a stored
procedure. The SP looks like this:
SET TERM ^ ;
CREATE PROCEDURE SP_NEW_TASK
RETURNS (
"uidTask" INTEGER)
AS
begin
|
by: Sara |
last post by:
How to call a .net dll method from sql server 2000 stored procdure
|
by: satish |
last post by:
hi,
i am a learner of ms -sql server 2000, i had a doubt in stored
procedures
suppose i have a data base having 20 tables, all the tables have a
column named--DATE
can we write a store procdure to find out the data ---i mean i want
the data entered
between two days ---- if i call the stored procedure in any one of the
|
by: Milkstr |
last post by:
Can anyone help, i'm just starting out with MS SQL on a new web page and i'm having problems writing a stored procdure, its for a simple forum on a web page.
I have a table with the main forum information, i then have a stored procdure
"SELECT Count(forum.ID) AS CountOfID, forum.partID
FROM forum
GROUP BY forum.partID
HAVING (((forum.partID)<>0));"
this is to work out which is the main posts and not the replies, i then have the main...
|
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...
| |
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |