Avoiding ASPNETDB SQL Database?

Sep 7, 2007

Hello.

I have been developing a small site that has two backend SQL Server databases.  One for my application data and one for the ASPNETDB database that is created by the ASP .NET Configuration utility.

Is it possible to configure the ASP .NET Configuration tool to use my custom database instead of creating a second database called ASPNETDB?

Thanks in advance.

Kev

View 2 Replies


ADVERTISEMENT

Moved Aspnetdb To SQL Server - What Permissions Do I Need To Give The ASP IIS Service Account For That? (Getting: Cannot Open Database Aspnetdb Requested By The Login. The Login Failed.)

May 12, 2008

I am getting the error:
Cannot open database "aspnetdb" requested by the login. The login failed.
When I browse to my ASP.NET 3.5 LINQ web application on the IIS 6.0 server on Server 2003.
I imagine this is because while I granted SQL Server 2005 login and permissions to my database that the application stores its data in, I did NOT grant any rights to the service account the IIS Application Pool uses for its identity to the aspnetdb database on SQL Server which is where all my roles information is stored at.
My question is what are the MINIMUM permissions needed for this database so it can perform its roles related functions?
I'm using Windows Authentications with the SQL Role provider for authorization.
 
Thank you.
 
 
EDIT: I think I only need to open the aspnetdb database and add my login to the aspnet_Roles_FullAccess role.  Is that correct?

View 2 Replies View Related

ASPNETDB To Another Database

Apr 19, 2007

Hi there readers of this post,
Do you know how to transfer the database (ASPNETDB.mdf) tables made by the ASP.NET admin tool into another database?
I want to run everything from 1 database.
regards
Sat

View 1 Replies View Related

How Can I Open A .mdf AspnetDB DataBase ?

Jul 24, 2007

Hello everybody, I am working with SqlExpress and MSSQL Server Management Studio Express and do not manage to open the aspnetDB .mdf database in which I am storing all data about my users.I woulds like to open it and to be able to request it in order to check some strange things.Actually, I'm experiencing an isssue with that database since the request just below gives me two results for only one user: SELECT Member.Password, Member.PasswordAnswer
FROM aspnet_MemberShip Member, aspnet_Users Users
WHERE Member.UserId=Users.UserId AND Users.UserName='Admin'  Using this request returns me a user whom password is clear and an identical user whom password is hashed whereas I set PasswordFormat="Clear" in my Web.ConfigCould you explain me how I may proceed please? Thanx for your help   

View 3 Replies View Related

Default ASPNETDB Database

Nov 28, 2007

Hi
I want to set up my web app to use a web parts personalization, I notice that a default database named aspnetdb is made, I also made one in my sql server using the aspnet_regsql.exe to make it.  Now what I need to find out is how to make my app point to the database in the sql server instead of making that default one.
 
Thanks

View 8 Replies View Related

Aspnetdb To Main Database?

Jan 6, 2008

When I created my website in Visual Studio 2008, I ended up with two databases.  The one I created (Speedway.mdf), then VS2008 added a new one (aspnetdb) when I added membership data (roles, users..etc).  Since the host I'm using charges for each database, I just want to move all my membership information into Speedway.mdf.  I exported the tables from aspnetdb.mdf to Speedway.mdf, but now I don't know how to tell the site to look at Speedway.mdf to find the membership info?

View 6 Replies View Related

ASPNETDB.MDF, My Own Database And Deployment

May 29, 2006

This question has been asked before, with vague responses
I'm using Visual Web Developer 2005 Express, SQL Server 2005 Express and SQL Server Management Studio Express.
When I create an application with Login controls, VWD automaticlly creates a ASPENTDB.MDF security database. I also create my own database for my application e.g. abc.mdf. In other words, I have two databases. However, my hosting company supports only one database. What do I (we) do?
I have seen articles on: aspnet_regsql . Does this create a new database with all the security features of ASPNETDB.MDF built into my new database i.e. abc.mdf?
(A) If yes, how do you run it with SQL Server Managment Studio Express? It sounds silly, but I need instructions here please ... Also, do you run this against abc.mdf or do you use it create abc.mdf?
(B) If not, how do you achieve a single database scenario?
I'm sure this is a very common deployment question, which is very confusing for most of us hobbyists that want to deploy their web applications

View 2 Replies View Related

Combine Aspnetdb With The Application's Database

Sep 19, 2006

I have tried to find all the threads related to this topic.  At this point I would like to find out what the best practices are for doing this. I plan to use Membership, Roles, and the login controls to handle my authentication and permissions issues.  I want to use the same database for my application data as for Application Services, using a standard SQL Server. So far, the easiest way to set this up that I can think of is to:1. Use aspnet_regsql.exe to create the Application Services Database schema2. Edit the "LocalSqlServer" entry in <connectionStrings> to point to the above database3. Add the tables, views, stored procedures, etc., that I need for my application into the database created in step 1Is there any more configuration I need to do to get Membership and Roles working?  When I did the Walkthrough, step 2 seemed to be the only requirement for getting Membership and Roles to work.Will I run into any trouble using LocalSqlServer for my application data updates?I would be interested in any other approaches to setting up a combined database, including opinions why and why not to do it.

View 1 Replies View Related

Need To Select From ASPNETDB And Other Database In One Query

Feb 3, 2007

Hello everyone,
I have a problem with making such a query. I have two databases: DB1 and ASPNETDB - default asp database. I get data from DB1.Books and want to join (INNER JOIN) UserID with UserName from ASPNETDB.Users.
The ponint is that I don't know how to access ASPNETDB in the query. I use SQLDataSource control in which I specified the ConnectionString pointing to DB1 database on my local SQL Server 2005 Express.
On the other hand, if I use a ConnectionString pointing to ASPNETDB as a database dynamically attached from file (~/App_Data/ASPNETDB.MDF), I gain access to the Users table but I get an error message when I try to access DB1.dbo.Books...
I'm getting sick of it.. thanks for any help!
 
kind regards

View 3 Replies View Related

ASPNETDB Replaces My Database In Connection

Aug 17, 2007

Hi,I've a little problem. When I connect my local server by this connection string: Data Source=NB126SQLEXPRESS;Initial Catalog=TVRM;Integrated Security=True I get content of ASPNETDB.MDF (placed in App_Data directory) instead content of my own database named TVRM. Please help...

View 2 Replies View Related

ASPNETDB - Unable To Connect To SQL Server Database

Dec 5, 2006

Hi Eevryone:
I seem to have corrupted my ASP.net Web Site Administration Tool some how.  It worked fine a few days ago, but reloaded SQL Server 2005 Express Edition W Adv Services SP1 yesterday I can not get past the "Unable to connect to SQL Server database" error.  I have run the aspnetdb.exe and created both a aspnetdb.mdf and loaded the tables to into a existing mdf.  I have checked all the permissions. 
So any ideas on what I am doing wrong, or can you point me to some documentation on the 'AspNetSqlProvider'
 
Thanks in advance, Gene

View 4 Replies View Related

Error Connecting To ASPNETDB - Cannot Open Database

Feb 15, 2007

Hi everyone, i have already created posts about this problem and im aware theres millions of replys, but i still cant get this to work and its driving me mad. The posts i have seen i dont understand?
 Im using the standard ASPNETDB Database, i have never opened up SQL Server Management studio, although i do have the express edition.
i have tried everything and i am totally stumped as to what to do. Heres my web.config.
It works in VWD 2005 Express, but not in WWWROOT or on webserver?
PLEASE PLEASE PLEASE Can someone help me!!!!!!!!!
 Dan :)
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="northwindsConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|MyDatabase.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.web>
<profile>
<properties>
<add name="FullName" defaultValue=""/>
</properties>
</profile>
<roleManager enabled="true" />
 
<compilation debug="false" />
<authentication mode="Forms" />
 
</system.web>
</configuration>

View 6 Replies View Related

Multiple Users Of A Website Using Aspnetdb.mdf Database

Jul 15, 2007

I don't know whether this question belong here, but....
In the past I had many customers using the same website each with their own domain name and their own database. To accomplish that, I used MS Access and placed each customers database in separate directories. I steered the customer to the correct directory using their domain name. I am now trying to accomplish the same thing using aspnetdb.mdf and other .mdf database files. I am using the aspnetdb.mdf database for membership, etc. I want the aspnetdb.mdf database file to be unique for each customer. Does anyone know how to accomplish what I was doing with MS Access using aspnetdb.mdf? Is there any way to have multiple web.config files each of which would be dedicated to a particular customer?
 

View 1 Replies View Related

Aspnet_regsql - Aspnetdb Working With My Existing Database

Jan 2, 2008

I installed ASPNETDB with the standard script, but then learned it was possible to integrate this membership db into my existing db (haven't done this yet, but will tomorrow then I'll delete the auto-created ASPNETDB for clarity).That's Great. Now.....I'm not sure the best way to tie this information into with my existing data. I assume I should use the UserID field but how should I do it? Should I update my existing customers table with a copy of the UserID value upon creation? If so, how do I do that?  I can create the relations between whichever tables, but I am curious as to your recommended method.Thanks for your help.jb 

View 5 Replies View Related

Detach Aspnetdb Database Database

May 6, 2008

Hi,
Iam facing problems to connect to the new database after detach the aspnetdb.Simply the new database disappear (In SQL 2005 Management studio express the database contents disappear ! and I get an error when try to open it).If I try to connectto aspnetdb again I get an error telling me it is used by another process.I don't understand what is going on could any one explain to me?  

View 12 Replies View Related

Aspnetdb Is On A Network Path That Is Not Supported For Database Files

Sep 1, 2006

I have two, probably related, problems:I have a very simple site. It will be used on the local intranet only. I want to use the windows authentication so users do not have to log on. The aspnetdb has been created using the configuration tool. If I use Server Explorer in vs to work on the site on my local machine, I can open aspnetdb, look at its tables, etc. If I use Server Explorer in vs to work on the site on the server, aspnetdb will not open and gives this error message:           ..."network path that is not supported for database files"...Other sites on the same server give the same message, but the sites work. I think this is because they can read the file but not write it; but that is a guess. We have tried everything; my head is ready to explode. We are using SQLServerExpress. It resides on the server's C drive (as does our data database). The web site, and hence the aspnetdb are on the F: drive of the same machine. Does SQLServerExpress treat the F: drive as a UNC drive? If so, are we in deep doo doo? I'm at a loss.As far as logging in: If I debug from vs, the login works beautifully both on my local machine and running from the server using vs. Login does not work when accessing the site from iexplorer. Mystified by that one, too. I tried to implement profiles and they crash, too; that led me to consider a write problem.Don't know what to do; any help is appreciated.

View 1 Replies View Related

Using Aspnetdb Express Database For Private Website Tables

Mar 23, 2007

Hi, I am using express database and tools. I have an aspnetdb express database because I am using the login controls, personalisation...Can I use this database for my private tables also? Or do I need a separate express database for my private tables? Will using aspnetdb database, which contains special asp.net tables, for my private website tables create any kinds of problems in using my website? I want to use a single express database for my website, not two different express databases.
Regards, Sandy

View 1 Replies View Related

Aspnetdb Connection Could Not Establish But Database Correctly Created.

Sep 2, 2007

I installed netframework 2.0 Visual Web developer and MSSQL 2005 express edition with SQL Server management express.I have got this configuration: 2*256 mb ram Intel Pentium 3.2Ghz Windows XP HUN SP2 latest version.server name: localhostSQLEXPRESSAuthentication: Windows AuthenticationI run aspnet_regsql.exe and the setup wizard created aspnetdb see here, Microsoft sql server management studio can see the database:But! When I run to the asp.net web application administration tool in Provider Configuration and chooseAspNetSqlProvider only 1then I click Select a single provider for all site management data link -> then testThe Tool write this:Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site
Administration tool, use the aspnet_regsql command-line utility to
create and configure the database, and then return to this tool to set
the provider. 

View 5 Replies View Related

Change Datatype For The UserID Column In The Aspnetdb Database

Jan 30, 2008

Is it possible to change the data type of the UserID column in the aspnetdb database from uniqueidentifier to int?

View 1 Replies View Related

Problem In Deploying Userlogin Database On Webserver Aspnetdb.mdf

Feb 3, 2007

I read scott's tutorial for Deploying database to Hoster's server

"Recipe: Deploying a SQL Database to a Remote Hosting Environment (Part 1)"

bt cud nt upload n get the user login functinality wrking..

so plz help me..

View 1 Replies View Related

SQLEXPRESS Database Issue - Cannot Open Database ASPNETDB.MDF Requested By The Login, Login Failed

Aug 29, 2006

Hello Guys

This is my connection string

<add name ="ASPNETDBConnectionString1" connectionString ="Data Source= .SQLEXPRESS; Integrated Security = True; DataBase = ASPNETDB.MDF; User ID = MyWindowsUserName; Password = MyWindowsPassword; User Instance = False; Connect Timeout = 30" providerName ="System.Data.SqlClient"/>

I tried to research on the internet and i got a solution on changing the permissions for this database to enable user SystemName/ASPNET, but iam not able to access this ASPNETDB.MDF from SqlServer and if i go to server explorer in vs2005, i dint know where to chage the permissions.

Can anyone help me on this.

Thanks a lot

View 15 Replies View Related

An Attempt To Attach An Auto-named Database For File Aspnetdb.mdf

May 1, 2007

having exhaustively searched the forum and tried everything over the pas few days im still recieving :Error Caught in Application_Error eventError in: http://mysite.com/site1/index.aspxError Message: An attempt to attach an auto-named database for file E:Inetpubwwwrootmvate.comWapCmsApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.Stack Trace:   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)   at System.Data.SqlClient.SqlConnection.Open()   at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate)   at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)   at System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc)   at System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties)   at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)   at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)   at System.Configuration.SettingsBase.get_Item(String propertyName)   at System.Web.Profile.ProfileBase.GetInternal(String propertyName)   at System.Web.Profile.ProfileBase.get_Item(String propertyName)   at System.Web.Profile.ProfileGroupBase.GetPropertyValue(String propertyName)   at ProfileGroupUser.get_ClientID()   at InfoPage.Page_PreInit(Object sender, EventArgs e)   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)   at System.Web.UI.Page.OnPreInit(EventArgs e)   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)help and suggestions appreciated 

View 1 Replies View Related

Why No Config.exe File In Book ASPnet 2.0 SBS By George Shepherd, To Install ASPNETDB Database?

Feb 7, 2008

For MS Press Book, ADO.NET 2.0 Step by Step, 2005 Edition by Rebecco Riordan, installing the code samples created a ConfigDB.exe file
under SampleDBs folder. Running this exe file created a AdoStepByStep into the Database
folder in SQL Server 2005 Express. 

However, for ASP.NET 2.0 Step by Step, 2005 Edition, by George Shepherd, there is no Config.exe to install the ASPNETDB SQL Server
2005 Express database. I right clicked the Database folder to 'Attach' the database.  But,
the database just showed a 'c: ASPNETDB.MDF filfe path as a name. Further, running
the aspx files in Chapters 7 and 12 showed a 'Timeout Expired' error msg, indicating
something wrong with accessing the SQL Server database.

How can I run the aspx files in Chapters 7 and 12?  How can I install the ASPNETDB?

TIA,
Jeffrey

View 4 Replies View Related

SQL Server 2005 And Express Permissions Nightmare/Cannot Open Database ASPNETDB.MDF Requested By The Login

Apr 12, 2007

I just spent the better par of 3 days creating a prototype in ASP.Net 2.0 and SQL Server Express only to discover that nobody from outside can see it...
ERROR with impersonation=true
User does not have permission to perform this action.
ERROR with impersonation=false
Unable to open the physical file "c:inetpubwwwroot------.mdf". Operating system error 5: "5(Access is denied.)".An attempt to attach an auto-named database for file c:inetpubwwwroot-----.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.  
What makes this so difficult?
What am I missing?
 

View 9 Replies View Related

Avoiding The Usage Of DTC

Apr 17, 2007

Hello

I am running an script and the following sentence throws and error because the DTC service is not running in the Remote Server:

insert into MyLocalTable
execute synonym_MyRemoteProcedure @SomeParameter

Since a transaction is not declared within the script, why is the DTC required?
How can I avoid the usage of the DTC? Is there a way to say "this code is not within a distributed transaction"?

Thanks a lot.

View 1 Replies View Related

Help In Avoiding The Use Of A Cursor

Apr 8, 2008

Here is a simplified example of a problem I am facing.

I have 2 tables: Tasks and Employees.

Tasks:
(Task_ID, Task_Name, Task_Type, Task_Requirement, Employee_ID)
Employees:
Emp_ID, Emp_Name, Emp_Specialty, Emp_Task_Cnt, Max_Task_Cnt

Requirements: Write a MS SQLServer 2000 Storeed Procedure to:
1. Update the Tasks table by assigning the task to an Employee.
2. Incrememnt the employee's Emp_Task_Cnt for each Task assigned.
3. Match the Employee to the Task by matching the Task_Requirement to the Emp_Specialty.
4. Do not exceed the employee's Max_Task_Cnt.

I have a working solution to the requirements, but it involves using cursor logic. For all the obvious reasons, I wanted to avoid using a cursor (or cursor-like looping structure) but could not figure out any other way to avoid processing the Task table one record at a time because of the: "4. Do not allow an Employee's Task_Cnt to exeed the Max_Task_Cnt."

Q: Is there a way to do this without using a cursor and still meet all of the requirements?

View 2 Replies View Related

Avoiding Caching

May 9, 2007

I'm trying to performance tune a procedure and am sort of being thwarted by caching.

When I first run the procedure, it takes a few seconds which is too long in this case. Subsequent executions in Management Studio are nearly instantaneous, though, which I imagine is due to caching and does not reflect the behavior of the procedure in production.

Is there a way to disable caching so that each execution of the procedure in Management Studio will be consistent and reflect the "first run" performance?

View 3 Replies View Related

Avoiding Cursor

Sep 7, 2007

This query uses a cursor to fetch a parameter and pass it to another Stored proc. Is there a straightforward way to do this without using a cursor?

declare @deleteunassigned int
declare cur_unassigned cursor for select distinct a.cust_cont_pk
from cust_cont a, cont_fold_ass b (NOLOCK)
where a.cust_cont_pk != b.CUST_CONT_PK
open cur_unassigned
fetch next from cur_unassigned into @deleteunassigned
while @@fetch_status = 0
begin
exec spDeleteCustContbypk @deleteunassigned
fetch next from cur_unassigned into @deleteunassigned
end
close cur_unassigned
deallocate cur_unassigned
GO


declare @deleteunassigned int
declare cur_unassigned
cursor for
SELECT DISTINCT a.cust_cont_pk
FROM cust_cont a,
cont_fold_ass b (NOLOCK)
WHERE a.cust_cont_pk != b.CUST_CONT_PK
open cur_unassigned
FETCH NEXT FROM cur_unassigned INTO @deleteunassigned
while @@fetch_status = 0
begin
exec spDeleteCustContbypk @deleteunassigned
FETCH NEXT FROM cur_unassigned INTO @deleteunassigned
end
close cur_unassigned
deallocate cur_unassigned
GO



Future guru in the making.

View 2 Replies View Related

Avoiding Compilation

Jul 20, 2005

Using small stored procs or sp_executesql dramatically reduces the number ofrecompiles and increases the reuse of execution plans. This is evident fromboth the usecount in syscacheobjects, perfmon, and profiler. However I'm ata loss to determine what causes a compilation. Under rare circumstances theusecount for Compiled Plan does not increase as statements are run. Seemsto correspond to when there is no execution plan. It would seem to me thatcompilation is a resource intensive task that if possible (data and schemaare not changing) should be held to a minimum.How does one encourage the reuse of compile plans?Is this the same as minimizing compilation?Looks like some of this behavior is changing in SQL 2005....Thanks,Danny

View 3 Replies View Related

Avoiding Deadlock

May 4, 2006

I have a stored procedure spUpdateClient, which takes as params a number of properties of a client application that wants to register its existence with the database. The sp just needs to add a new row or update an existing row with this data.

I tried to accomplish this with code somethign like this. (The table I'm updating is called Client, and its primary key is ClientId, which is a value passed into the sp from the client.)


IF (SELECT COUNT(ClientId) FROM Clients WHERE ClientId=@ClientId) = 0
BEGIN
-- client not found, create it
INSERT INTO Clients (ClientId, Hostname, Etc)
VALUES (@ClientId, @Hostname, @Etc)
END

ELSE

BEGIN
-- client was found, update it
UPDATE Clients
SET Hostname=@Hostname, Etc=@Etc
WHERE ClientId=@ClientId
END
But the client apps call this every second or so, so soon enough I started getting primary key violations. It looks like one client would make two calls nearly at the same time, both would get a 0 value on the SELECT line, so both would try to insert a new row with the same ClientId. No good.
So then I added

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
at the top, and a COMMIT at the bottom. I thought the first one in would get to run the whole sp, and the next one in would have to wait for the first to be done.
Instead I'm now getting deadlock errors.
If I understand the docs right, that's because the exclusive lock is not placed on the Clients table until the INSERT happens, not at the SELECT. So when two calls to the sp happen at nearly the same time (call them A and B), A does the SELECT and that locks Clients so nobody else can update it. Then B does the SELECT, locking Clients so nobody else (including A) can update it. Now A needs to exclusively lock Clients to do its INSERT, but B still has that read lock on it, and they're deadlocked.
I could catch the deadlock in my client app after SQL Server kills one of the transactions, but it seems to me there should be some way to set a lock at the top of the sp that says "nobody else can enter this sp until I exit it". Any such thing?
Thanks.
Nate Hekman

View 9 Replies View Related

VS 2008 Express, New Install: Cannot Open Database Aspnetdb Requested By The Login. The Login Failed.

May 9, 2008

Hi,
I just installed Visual web developper 2008 express with all options including SQL srvr express 2005!

This is from default iso image on the official website.

I create my first project and when I want to do ASP.NET configuration from web site menu, i got this error:

"Cannot open database "aspnetdb" requested by the login. The login failed."

I am just trying to learn here so i even did not create any dB or something, it is 1st time I run configuration to add security roles and users for testing!

I also un-installed all and re-installed, still the same...

pleas help and give me details as i am new.

kind regards,Golgot

View 12 Replies View Related

Avoiding SQL Injection With Dynamic SQL

Aug 5, 2004

I am exclusively using Stored Procedures to access the database, i.e. there are no Ad-Hoc SQL statements anywhere in the C# code. However, one thing I need to be able to do is to allow filtering for data grids on my ASP.NET page. I want to do the filtering in the Stored Procedure using Dynamic SQL to set the WHERE clause. However, one fear of mine is SQL injection from the client. How can I avoid arbitrary SQL injection, yet still allow for a dynamic WHERE clause to be passed into the stored procedure?

Jason Pacheco

View 2 Replies View Related

Avoiding Query In Loop

Jun 9, 2008

Hello all,

I currently have an asp script that is generating a 12 month rolling report. From asp I'm running a for loop with 12 iterations, each one sending the following query:

select count(a.aReportDate) as ttl from findings f left outer join audits a on a.aID = f.auditID
where f.findingInvalid <> 1 and month(aReportDate) = " & Mo & " and year(aReportDate) = " & Yr

where the Mo and Yr variables are incremented accordingly.

I actually have 4 sets of data being pulled back to populate a graph, so this results in 48 queries with each page load! Obviously not ideal. So I'm hoping to reduce this to 4 queries. I was playing with the following in enterprise manager:

DECLARE @DT DATETIME
DECLARE @CNT INT
SET @DT = '10/31/07'
SET @CNT = 1
WHILE(@CNT < 12)
BEGIN
select count(a.aReportDate) as ttl from findings f left outer join audits a on a.aID = f.auditID
where f.findingInvalid <> 1 and month(aReportDate) = month(@DT) and year(aReportDate) = year(@DT)

SET @CNT = @CNT + 1
END

I haven't yet added any logic to increment the date, but my concern is that it looks like it is returning 12 separate results. Is there any way to combine this all into one resultset that will be passed back to my asp script? Hopefully this makes sense?

Suggestions on a completely different approach would also be welcome.

Thanks!

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved