I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to
deal with more sophisticated queries (may I call them so?) like stored
procedures. I have a form with a combobox for selections and a textbox to
enter a certain value. Let us say I call the combobox @select and the
textbox @find. The combobox always shows the first of the items to select.
Now I want to return a message if nothing is found, or if nothing has been
entered at all. The stored procedure reads for instance:
ALTER PROCEDURE OPC
@select nvarchar(20), @find nvarchar (100)
AS
SET NOCOUNT ON
IF
@find IS NULL
BEGIN
PRINT 'You didn't enter any value'
RETURN
END
IF
@select = 'Author'
BEGIN
SELECT *
FROM Books
WHERE Author LIKE '%' + @find + '%'
ORDER BY Author, Title, Publisher, Year
END
[And so on]
RETURN
This works correct when I enter something, but when I don't enter any value,
a message box pops up saying that the stored procedure has been executed,
but no records were found. I want to see an error message like above. It's
as simple as
ALTER PROCEDURE Hello
AS
BEGIN
PRINT 'Hello'
END
and nothing is seen. Does anybody know? Thank you.
Wim 6 2320
"Wim van Rosmalen" <wv******@tisca li.nl> wrote in message
news:41******** **************@ dreader2.news.t iscali.nl... I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have
to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of the items to select. Now I want to return a message if nothing is found, or if nothing has been entered at all. The stored procedure reads for instance:
ALTER PROCEDURE OPC @select nvarchar(20), @find nvarchar (100)
AS
SET NOCOUNT ON
IF @find IS NULL BEGIN PRINT 'You didn't enter any value' RETURN END
IF @select = 'Author' BEGIN SELECT * FROM Books WHERE Author LIKE '%' + @find + '%' ORDER BY Author, Title, Publisher, Year END
[And so on]
RETURN
This works correct when I enter something, but when I don't enter any
value, a message box pops up saying that the stored procedure has been executed, but no records were found. I want to see an error message like above. It's as simple as
ALTER PROCEDURE Hello AS BEGIN PRINT 'Hello' END and nothing is seen. Does anybody know? Thank you.
Wim
I'm not at all sure, but if your code works as expected in Query Analyzer,
but you're running from an ADP, then perhaps Access is not handling the
PRINT output correctly - it's returned as an informational error (see "Using
PRINT" in Books Online). You might want to investigate how Access handles
this specific output - posting in an Access newsgroup might be useful.
Simon
Wim van Rosmalen (wv******@tisca li.nl) writes: I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of the items to select. Now I want to return a message if nothing is found, or if nothing has been entered at all. The stored procedure reads for instance: ... IF @find IS NULL BEGIN PRINT 'You didn't enter any value' RETURN END ...
This works correct when I enter something, but when I don't enter any value, a message box pops up saying that the stored procedure has been executed, but no records were found. I want to see an error message like above. It's as simple as
SQL Server is not Access, so a PRINT statement does not by itself outupt
something anywhere. It is up to the client to pick it up. And then you
will have to code for it in the client. From Access, you usually access
SQL Server from ADO, and ADO is not very good making messages avilable
anyway.
You may want to try to use RAISERROR instead:
RAISERROR('You didn''t enter any value', 11, 1)
this causes ADO to raise an error as well.
Disclaimer: I don't know Access or ADP, but I'm speaking from general
experience of ADO programming.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Thanks Erland! I knew about RAISERROR, but in a S.P. like this, PRINT is
returned by the same configuration (MSDE, which doesn't have a
query-analyser):
ALTER PROCEDURE StoredProcedure 1
AS
SET NOCOUNT ON
DECLARE @msg varchar(255)
-- If 53000 is changed into 3000, titles beginning with TE are displayed.
-- If 53000 (or any high number) is not changed, titles beginning with TA
are displayed.
IF (SELECT COUNT(Nr)
FROM RecordTable
WHERE Title LIKE 'Ta%' AND Nr BETWEEN 2000 AND 53000) > 0
BEGIN
SET NOCOUNT ON
SET @msg = 'Error Message Nr. One'
PRINT @msg
SELECT title
--If the name "RecordTabl e" is changed, Error Message Nr. One is displayed
(related to a high number;.
--related to a low number an empty table is displayed).
FROM RecordTable
WHERE title LIKE 'Ta%'
END
ELSE
BEGIN
SET NOCOUNT ON
SET @msg = 'Error Message Nr. Two'
PRINT @msg
SELECT title
--If the name "RecordTabl e" is changed, Error Message Nr. Two is displayed
(related to a low number;.
--related to a high number titles beginning with TA are displayed).
FROM RecordTables
WHERE title LIKE 'Te%'
END
Best regards,
Wim van Rosmalen
"Erland Sommarskog" <es****@sommars kog.se> schreef in bericht
news:Xn******** **************@ 127.0.0.1... Wim van Rosmalen (wv******@tisca li.nl) writes: I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of the items to select. Now I want to return a message if nothing is found, or if nothing has been entered at all. The stored procedure reads for instance: ... IF @find IS NULL BEGIN PRINT 'You didn't enter any value' RETURN END ...
This works correct when I enter something, but when I don't enter any value, a message box pops up saying that the stored procedure has been executed, but no records were found. I want to see an error message like above. It's as simple as
SQL Server is not Access, so a PRINT statement does not by itself outupt something anywhere. It is up to the client to pick it up. And then you will have to code for it in the client. From Access, you usually access SQL Server from ADO, and ADO is not very good making messages avilable anyway.
You may want to try to use RAISERROR instead:
RAISERROR('You didn''t enter any value', 11, 1)
this causes ADO to raise an error as well.
Disclaimer: I don't know Access or ADP, but I'm speaking from general experience of ADO programming.
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Wim van Rosmalen (wv******@tisca li.nl) writes: Thanks Erland! I knew about RAISERROR, but in a S.P. like this, PRINT is returned by the same configuration
Yes, ADO is inconsistent in how it handles PRINT statements. It does
slightly better on errors.
(MSDE, which doesn't have a query-analyser):
You can use the command-line tool OSQL to run the queries. There you
will always see the PRINT statements.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
O.K. Erland, thanks again!
Wim
"Erland Sommarskog" <es****@sommars kog.se> schreef in bericht
news:Xn******** **************@ 127.0.0.1... Wim van Rosmalen (wv******@tisca li.nl) writes: Thanks Erland! I knew about RAISERROR, but in a S.P. like this, PRINT is returned by the same configuration
Yes, ADO is inconsistent in how it handles PRINT statements. It does slightly better on errors.
(MSDE, which doesn't have a query-analyser):
You can use the command-line tool OSQL to run the queries. There you will always see the PRINT statements.
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
For MS verbiage on the topic, take a look at http://support.microsoft.com/default...NoWebContent=1
"Wim van Rosmalen" <wv******@tisca li.nl> wrote in message
news:41******** **************@ dreader2.news.t iscali.nl... O.K. Erland, thanks again!
Wim
"Erland Sommarskog" <es****@sommars kog.se> schreef in bericht news:Xn******** **************@ 127.0.0.1... Wim van Rosmalen (wv******@tisca li.nl) writes: Thanks Erland! I knew about RAISERROR, but in a S.P. like this, PRINT
is returned by the same configuration
Yes, ADO is inconsistent in how it handles PRINT statements. It does slightly better on errors.
(MSDE, which doesn't have a query-analyser):
You can use the command-line tool OSQL to run the queries. There you will always see the PRINT statements.
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: 8leggeddj |
last post by:
Hello,
I am having a problem when using access xp as a frontend for sql server
2000.
I have been trying to update a number of stored procedures (Just simple
adding fields etc) which results in access crashing with event ID 1000 and
1001.
Does anyone have any ideas as to what could be the problem?
Thanks in advance..
|
by: MD |
last post by:
I am trying to create a dynamic SQL statement to create a view.
I have a stored procedure, which based on the parameters passed calls
different stored procedures. Each of this sub stored procedure creates
a string of custom SQL statement and returns this string back to the
main stored procedure.
This SQL statements work fine on there own. The SQL returned from the
sub stored procedure are returned fine. The datatype of the variable
that...
|
by: Compkitty |
last post by:
Hi, I'm sort of new to Stored Procedures; and I'm building a search
page where there are 9 parameters the user can put in; as little as
1, at most 9.. then it runs the Stored P and looks at the values.
I am using the COALESCE; to skips nulls,... but I'm still not getting
the right results.. either I get 0 or 4000..
CREATE PROCEDURE Sp_Search
(
@AcctNum varchar (100),
|
by: Cesco |
last post by:
Hallo to everybody. I have a DTS in SQL Server 2000 and I need to
execute it from stored procedure.
I know that there are various method fot does this but they doesn't
work.
The first method that I try to use is with the stored procedure
"xp_cmdshell".
If I write in DOS prompt
dtsrun /F c:\DTS1.dts
the DTS1 will execute well
|
by: Thomasb |
last post by:
With a background in MS SQL Server programming I'm used to temporary
tables. Have just started to work with DB2 ver 7 on z/OS and stumbled
into the concept of GLOBAL TEMPORARY TABLE.
I have created a temporary database with a tables space. Verified that
DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER);
INSERT INTO SESSION.TEMP VALUES(10);
SELECT A FROM SESSION.TEMP;
works from a query tool.
| |
by: Wojciech Wendrychowicz |
last post by:
Hello to All,
I'm trying to retrieve records from AS/400 in an VBA application.
So, I've made an RPG program, then a stored procedure wchich calls that RPG
program, and finally some VBA code to call the stored procedure and retrieve
data from AS/400.
The problem is, that when I finally run my VB code, it just hangs.
But when I call the same stored procedure from "pure" SQL - it works
perfect. (I evaluate Aqua Data Studio 3.7)
What I...
|
by: RSH |
last post by:
Im trying to create a stored procedure of the following code. I want to set
it so that I have to send the first 4 variables (@DB,
@BackUpFile,@TestDB,@RestoreFile). I am having trouble when i try to save
it...SQL Server wants me to decalre the variables. How would I go about
making this a stored procedure correctly?
Here is the code:
USE master
GO
|
by: Frawls |
last post by:
Hi
I Am am having problems with a stored Procedure that i wrote.
Basically whats happening is that the Stored procedure Runs fine when i
EXECUTE it in SQL Query analyzer.
But when i debug through the application in Visual Studio .NET 2003 the
application an exception when it executes the query.
|
by: jamesclose |
last post by:
My problem is this (apologies if this is a little long ... hang in there):
I can define a function in VB.NET with optional parameters that wraps a SQL procedure:
Sub Test(Optional ByVal Arg1 As Integer = 0, _
Optional ByVal Arg2 As Integer = 0, _
Optional ByVal Arg3 As Integer = 0)
' Call my SQL proc with the same signature
|
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: 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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: 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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |