Friday, February 15, 2008
No anchor member was specified for recursive query Problem
The main problem I was having was figuring out how the recursive member integrates with the CTE table. I kept getting the following error.
No anchor member was specified for recursive query "MemberRelation".
After a few hours of troubleshooting I realized that I didnt fully understand what the first line of code for the CTE was doing. In actuality, it is describing the table layout of the result set. (Not a table in the database.) Now the expression is working and making sense:
with MyRelation
(
ID1,
ID2,
Level
)
as
(
-- Anchor member definition
select ID1
,ID2
,0 as Level
from relation as e
UNION ALL
-- Recursive member definition
select e.ID1
,e.ID2
,Level + 1
from relation as e
join MyRelation R on R.ID2 = e.ID1
)
-- Statement that executes the CTE
select top 1 * from MyRelation
where Level = 3
option(Maxrecursion 3)
GO
Thursday, February 14, 2008
TFS - Getting files that have changed since a particular date
Here is how you do it:
1. Create a new folder on your local hard drive to be used temporarily.
2. In visual studio, create a new workspace mapping the directory in source control you want to get the changes on, to the folder created in step 1 above.
3. Under source control, right-click on the folder and select "Get Specific Version..." on the directory that you want to get the changes on.
4. From the Version checkbox, choose "Changeset" and enter the changeset that has the files without the changes you are retrieving.
5. Click Get to get all the files.
6. Once complete, go to the directory on your local hard drive (created in step 1) and delete all the files you just retrieved.
7. Under source control, right-click on the folder you wish to get the changes on and select "Get Latest Version"
After all the files are done downloading, your local folder will only have files that have changed since you last retrieved the files in step 3. Why? - "Get Latest Version" doesnt actually look at the files on your local machine to determine what files need to be updated. Instead, it keeps track of the files you downloaded on the server and gets any changes from your previous download.
Saturday, February 2, 2008
GenerateAndPersistNewIndex causing "Not enough storage is available" error
Here is a good “gotcha” for the GenerateAndPersistNewIndex setting in the Fuzzy Lookup component delivered with SSIS and SQL 2005.
Problem: MaxMemoryUsage set to 0 (Unlimited) - When this is set to 0, and the MatchIndexOpetion set to GenerateAndPersistNewIndex, the package will fail stating: "Not enough storage is available to complete this operation"
Fix: Set MaxMemoryUsage to 256
There are a few things really odd things that I've discovered:
· The description of MaxMemoryUsage from MS says it applies to the transformation process, not the index creation process.
· With MaxMemoryUsage set to 0 and plenty of RAM, the package may still fail even though it isnt close to maxing out the RAM.
· Even with MaxMemoryUsage set to 256, it is going past this memory requirement. (although I can see it is using a lot less memory than with a setting of 0)
Tuesday, October 23, 2007
Troubles debugging javascript with IIS 7 and asp.net
I've gone through all the usual recommendations on the web.... turn off "Disable javascript debugging" on IE; turn on script debugging in visual studio; turn on script debugging in IIS 7.0. All are required but still didnt seem to allow the debugger to break into the script.
As it turns out, my problem only showed when I used the Page.RegisterStartupScript method... loading my scripts via the code-behind. Reverting back to the original html include statements fixed everything. Not sure what was going on here... I did a little bit more investigation but nothing conclusive.
Before (Mainpage.cs):
public void OnInit()
{
string js = ReadResourceString("includescript.js");
ClientScript.RegisterStartupScript(typeof(Page), "UIScriptHelper", js);
}
After (Mainpage.aspx):
...
<head>
<script type="text/javascript" src="includescript.js"/>
/head>
Thursday, October 18, 2007
useDefaultWebProxy causing problems when calling the WCF service
When my web application was running we would occassionally get timeouts when the client tried to contact the service. Resetting IIS would solve the problem, but obviously that is not a desired solution.
Solution:
Set useDefaultWebProxy=false from httpTransport element of the app.config or web.config. For some reason, when this setting was set to true the client would have problems sending requests that were executed rapidly in succession. This would cause a problem in the UI when two independent users sent requests near the same time.
Tuesday, April 3, 2007
Using Partials to extend the functionality of a DataTable
Previously, if I was working with data with one table (lets say Employees) and I wanted to find all the orders with a particular employee, I would go about it something like this:
EmployeesTableAdapter eta = new EmployeesTableAdapter();
EmployeesDataTable edt = pta.GetEmployee();
foreach (EmployeesRow er in edt)
{
if(er.Name == "George")
{
//do our work with the orders data
}
}
The cool thing about the code generated is that the class information is created as partial classes. With the use of partial classes, we can extend the partial class in our own code and as such, extend the functionality that is available for a particular row.
public partial class SuppliersRow
{
public EmployeesDataTable GetEmployeesOrders()
{
OrdersTableAdapter ota = new OrdersTableAdapter();
return ota.GetOrdersByEmployeeID(this.EmployeeID);
}
}
With the functionality extended, we can have the row we are working with be responsible for retrieving the data associated with that row.
foreach (EmployeesRow er in edt)
{
if(er.Name == "George")
{
//do our work with the orders data
}
}
Monday, February 12, 2007
Debug timeout with IIS 7.0 and App pools
Problem:
When my application was broken into the debugger, after ~90 seconds, the debugger would stop working and I would have to restart it.
Looking into the eventlog, I found the following notices:
A process serving application pool ''failed to respond to a ping. The process id was '5472'.
Source of the Problem:
IIS has a setting for application pools that allows it to monitor the health of the process. When the process doesnt respond to a ping request (as in debug mode), IIS kills the process and therefore kills the debug session.
Solution:
1. Open IIS
2. Open the Advanced Settings for the application pool you are running under.
3. Find the setting "Ping Enabled" under "Process Model"
4. Change this to False.
Note: you could alternatively increase the Ping Maximum Response Time to a higher value.