473,407 Members | 2,629 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,407 software developers and data experts.

Can you pass parameters to a View?

I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In
a certain report I use a view as part of the query spec. For the view, at
present, I am querying for all the records in the table. But I am wondering
if there is a way, at runtime, to pass values to the View (like start date
and end date) so that I don't have to return every record in the table of my
view. If I can't pass a parameter, perhaps I can create a view, a-fresh,
with the parameters, each time I run the report. If I can, I don't know
what the syntax might be under Visual Studio Code nor where to go to find
it.

Could somone point me in the right direction?

Nov 20 '05 #1
6 3555
I'm not sure which reporting engine you are using, but it can be done with a
stored procedure for sure if your engine allows this. You can also make
stored procedures that use views, though you may not need the view anymore
with the SP.

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"Woody Splawn" <wo***@splawns.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In a certain report I use a view as part of the query spec. For the view, at
present, I am querying for all the records in the table. But I am wondering if there is a way, at runtime, to pass values to the View (like start date
and end date) so that I don't have to return every record in the table of my view. If I can't pass a parameter, perhaps I can create a view, a-fresh,
with the parameters, each time I run the report. If I can, I don't know
what the syntax might be under Visual Studio Code nor where to go to find
it.

Could somone point me in the right direction?

Nov 20 '05 #2
Hello Woody,

Thanks for posting in the group.

I noticed that you mentioned report in the post. Did you mean crystal
report?

Generally speaking, if we want to return specific rows from a DB, we could
use a select statement or a stored procedure in .NET programming, and then
use the returned records as the data source.

For an example, we could code like:

DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("server=myServer;user
id=myUID;password=a"b;database=northwind");
SqlDataAdapter da = new SqlDataAdapter("select * from customers where
customerid = ***",cn);
da.Fill(ds, "customers");

Also, there is a good document named ".NET Data Access Architecture Guide"
in MSDN. This document provides guidelines for implementing an
ADO.NET-based data access layer in a multi-tier .NET application. It
focuses on a range of common data access tasks and scenarios and presents
guidance to help you choose the most appropriate approaches and techniques.
We could reach it at
http://msdn.microsoft.com/library/en...asp?frame=true.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Woody Splawn" <wo***@splawns.com>
!Subject: Can you pass parameters to a View?
!Date: Thu, 13 Nov 2003 10:29:18 -0800
!Lines: 14
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#i*************@TK2MSFTNGP11.phx.gbl>
!Newsgroups: microsoft.public.dotnet.languages.vb
!NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156592
!X-Tomcat-NG: microsoft.public.dotnet.languages.vb
!
!I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In
!a certain report I use a view as part of the query spec. For the view, at
!present, I am querying for all the records in the table. But I am
wondering
!if there is a way, at runtime, to pass values to the View (like start date
!and end date) so that I don't have to return every record in the table of
my
!view. If I can't pass a parameter, perhaps I can create a view, a-fresh,
!with the parameters, each time I run the report. If I can, I don't know
!what the syntax might be under Visual Studio Code nor where to go to find
!it.
!
!Could somone point me in the right direction?
!
!
!
!

Nov 20 '05 #3
Thanks for responding
I noticed that you mentioned report in the post. Did you mean crystal
report?
I am using Active Reports
we could use a select statement or a stored procedure


Understood. I am already doing what you suggested. In one of my select
statments I user 4 tables and a view to produce the answer set. My question
has to do with whether I should pair-down the view (by selection criteria
that is indegeneous to the view) prior to running the big query. I have a
message posted on the SQL Server forum on this as well. Just trying to get
the best times (speed) possible.

I appreciate your and Microsoft's attention.

Woody
Nov 20 '05 #4
Hi Woody,

I am glad to be of assistance. Based on my experience, stored procedure
often improves performance. So I suggest you use it as much as possible. :)

Thanks again for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5
"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message <news:C1**************@cpmsftngxa06.phx.gbl>...
I am glad to be of assistance. Based on my experience, stored procedure
often improves performance. So I suggest you use it as much as possible. :)


The better to lock us in to SQL Server, right?

--
Joe Foster <mailto:jlfoster%40znet.com> Sign the Check! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
Nov 20 '05 #6
Hi,

I think it is a guideline even when we are programming on other DBs. I have
no much experience on other kinds of DBs. But they may also have some
techniques on DB sides which could improve the performance of program.
Please correct me if I have something wrong here. :)

From MSDN, we could see:

You should use stored procedures, instead of embedded SQL statements, for a
number of reasons:

Stored procedures generally result in improved performance, because the
database can optimize the data access plan used by the procedure and cache
it for subsequent reuse.

Stored procedures can be individually secured within the database. A client
can be granted permissions to execute a stored procedure, without having
any permissions on the underlying tables.

Stored procedures result in easier maintenance, because it is generally
easier to modify a stored procedure than it is to change a hard-coded SQL
statement within a deployed component.

Stored procedures add an extra level of abstraction from the underlying
database schema. The client of the stored procedure is isolated from the
implementation details of the stored procedure and from the underlying
schema.

Stored procedures can reduce network traffic, because SQL statements can be
executed in batches rather than sending multiple requests from the client.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7

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

Similar topics

6
by: HH | last post by:
I'm learning to design web applications with php, mysql, and apache from a book. I copied a sample application called guestbook 2000 that came with the CD in the book to my htdocs folder, but...
3
by: Benito | last post by:
Hi Everyone, Is there an easy way that I could pass a filter (variable) unto a view via stored procedures? I would appreciate your suggestions. Benito
11
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
9
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because...
2
by: gumby | last post by:
I would like to call this stored procedure, but I am unable to pass parameters to the @Start and @End. Is thier a way to pass parameters to a pass through query from MS Access? SELECT ...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

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.