Sunday, September 14, 2008
How to install adventureworks on SQL Server 2008
The program does not actually attach the database to sql server. It only creates a backup that can be restored. You now will need to do some additional configuring to SQL Server.
2. You need to enable FILESTREAM
http://msdn.microsoft.com/en-us/library/cc645923.aspx
3. Next run the following script
EXEC sp_configure filestream_access_level, 2
RECONFIGURE
4. Finally, you run a script that restores the backup of the installed database.
C:\Program Files\Microsoft SQL Server\100\Tools\Samples
Open RestoreAdventureWorks2008 and modify the set path:
SET @source_path = 'C:\Program Files\Microsoft SQL Server\100\'
Now, you should be able to run the TSQL and the database will be created in the following folder
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
Remember to refresh your database listing.
Friday, August 22, 2008
Linq - A Basic Understanding
You use LINQ to query objects, SQL and XML.
Linq relies heavily on delegates, anonymous methods and lambda expressions.
The foundation layout is as follows:
- Delegates exist for situations in which you want to pass methods around to other methods.
- An anonymous method is a block of code that is used as the paremeter for the delegate.
- Lambda expresions can be used with delegate types.
Using lambda expression reduces the number classes.
Lamba expressions can be used any place where type is a delegate.
The method that is invoked by the delegate does not need the exact same types ad defined by the delegate declaration. Convariance and contra-variance are possible.
- Return Type Convariance is when the return type can derive from the type defined in the delegate.
- The term parameter type contra-variance means that the parameters defined by the delegate might differ in the method that is called by the delegate.
To the left of the Lambda operator => are the parameters. It is ok not to added the parameter types because they are resolved by the compiler. The right side of the Lambda operator defines the implementation. With anonymous methods, curly brackets and the return statement are required. With Lambda expressions the syntax elements are not required because they are done by the compiler in any case. If you have move than one statement on the right side of the Lambda operator, curly brackets and the return stement are possible.
LINQ example
var query = from r in BroncRider.GetChampions() where r.State == "SD" orderby r.Wins decending select r;
for each (BroncRider in query) {Console.Writeline("{0:A}", r);
Notes:
- where r.State == "SD" is converted to Where (r => r.State == "SD")
- .orderby r.Wins decending is converted to OrderByDecending(r => r.wins)
The query expression must begin with a from clause and end with a select or group clause.
When the query expression is defined during runtime, the query does not run. The query runs when the items are iterated.
Let's have a look once more at the extension method Where(). This extension method makes use of the yield return statement to return the elements where the predicate is true. Because the yield return statement is used, the compiler creates an enumerator and returns the items as soon as they are access from the enumeration.
The collection is also to be sorted. This does not happen when the query is defined. Instead the iteration happens with the foreach statement, where all the items are iterated. Basically, the sort happens whenever you do a foreach. If you add items to the collection and later iteratate the items they will be sorted.
Friday, July 25, 2008
Create High Quality Thumbnails/Resize using System.Drawing.Graphics - ASP.Net C# Code - Chintankumar Patel's Blog
This is a great article on the steps necessary to correctly scale an image down.
Thursday, July 03, 2008
How to synch Infragistics Grid with the form detail.
Infragistics
Infragistics sample of how to synch a grid and form detail only works if the grid is not allowed to be sorted. Instead of using the grid's row position. The record position of the underlying binding source should be used.
ugGradingLocation - is the Infragistics grid
ScopingScenarioTypicalGradingSecBindingSource - is the binding source for the grid and form detail.
Sub GridSynchWithForm()
' Use CurrencyManager to set position (this will handle sorted grids)
If Me.ugGradingLocation.ActiveRow IsNot Nothing Then
Dim cmGrid As CurrencyManager = DirectCast(BindingContext(ugGradingLocation.DataSource, Me.ugGradingLocation.DataMember),
_ CurrencyManager)
Dim cmForm As CurrencyManager = Me.BindingContext(Me.ScopingScenarioTypicalGradingSecBindingSource)
If cmForm.IsBindingSuspended Then
cmForm.ResumeBinding()
End If
cmForm.Position = cmGrid.Position
'If the grid could not be synched with the from detail
'Assume the grid is adding a row and temporary suspend binding.
If cmForm.Position <> cmGrid.Position Then
cmForm.SuspendBinding()
End If
End If
End Sub
Called when the following events occur:
ugGradingLocation_AfterRowActivate
ugGradingLocation_AfterRowInsert
ugGradingLocation_AfterRowUpdate
Wednesday, July 02, 2008
DotNetNuke Installation Trouble Shooting
- If you are using windows VISTA, prior to unzipping the file, change the file property settings. You need to "unblock" the file. This is under the general settings tab.
- Read the readme file. It has importatant instructions like renaming files and setting up security. For example, rename release.config to web.config.
- Grant access to the database folder to NETWORKSERICE
- You may need to coment out the ScriptModule references in the WebConfig. You will know when you get an error.
- wizard i infiinte loop at "Run Database Installation Scripts"
Once you gotten to the page with "infinite loop" track back using back button
up to the initial page and select Auto instead. At that point your connection
string and other settings are already saved to web.config, so Auto will
just run and do what you wanted. Not sure why, but on local machine, it
always gives me that problem. I never had it out on a remote server,
though. Also, it is hardly an infinite loop. It seems to me that the wizard
just dies internally for some odd reason and, since I got the workaround, I
just don't care to dig any deeper. :)