tag:blogger.com,1999:blog-71922366688896727982024-03-21T22:13:45.477+00:00Spread your WealthChrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.comBlogger70125tag:blogger.com,1999:blog-7192236668889672798.post-13329449219973505642009-06-25T11:50:00.004+01:002009-06-25T16:07:46.601+01:00Common Table ExpressionsIntroduced in SQL 2005 was the Common Table Expression (CTE). These can act like subqueries or views within a SQL statement.<br /><br />Good definition on <a href="http://www.4guysfromrolla.com/webtech/071906-1.shtml">4GuysFromRolla</a> and <a href="http://msdn.microsoft.com/en-us/library/ms190766.aspx">MSDN</a>.<br /><br />To use them you use the 'WITH' keyword, for example if you were using the following Subquery:<br /><pre><br /><code><br />SELECT<br /> *<br />FROM<br /> (<br /> SELECT<br /> p.Forename<br /> , p.Surname<br /> , COUNT(m.MessageId) AS MessageCount<br /> FROM<br /> [Pupil] p<br /> INNER JOIN [Message] m ON (p.PupilId = m.PupilId)<br /> GROUP BY<br /> p.Forename<br /> , p.Surname<br /> ) AS PupilsWithMessages<br /></code><br /></pre><br />to get all pupils with a message you could now use a CTE,<br /><pre><br /><code><br />WITH PupilsWithMessages (Forename, Surname, MessageCount) AS (<br /> SELECT<br /> p.Forename<br /> , p.Surname<br /> , COUNT(m.MessageId) AS MessageCount<br /> FROM<br /> [Pupil] p<br /> INNER JOIN [Message] m ON (p.PupilId = m.PupilId)<br /> GROUP BY<br /> p.Forename<br /> , p.Surname<br />)<br /><br />SELECT<br /> *<br />FROM<br /> PupilsWithMessages<br /></code><br /></pre><br />This is a simple example but it looks a lot cleaner than subqueries and you can use them in the same way as you would a view. Better examples on the above links.<br /><br /><h4>Recursive CTE's</h4><br />You can also use them for recursing, a simple example I came up with was to loop through a comma delimited list of weekdays and return a seperate row for each one. Whereas previously you would need to use a Cursor you can now use a CTE.<br /><pre><br /><code><br />DECLARE @String varchar(100)<br />SET @String = 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,';<br /><br />WITH List (Val, Rest, HierarchyLevel) AS (<br /> SELECT<br /> SUBSTRING(@String, 1, CHARINDEX(',', @String)-1) AS Val<br /> , SUBSTRING(@String, CHARINDEX(',', @String)+1,200) AS Rest<br /> , 1 AS HierarchyLevel<br /> UNION ALL<br /> SELECT<br /> SUBSTRING(l.Rest, 1, CHARINDEX(',',l.Rest)-1) AS Val<br /> , SUBSTRING(l.Rest, CHARINDEX(',', l.Rest)+1,200) AS Rest<br /> , l.HierarchyLevel + 1 AS HierarchyLevel<br /> FROM<br /> List l<br /> WHERE<br /> CHARINDEX(',', l.Rest) <> 0<br /> --AND HierarchyLevel < 5 /*You can limit how 'deep' the recursion goes*/<br />)<br /><br />SELECT<br /> *<br />FROM<br /> List<br /></code><br /></pre><br />In the 2nd query the CTE references itself (List) to continue splitting up the string until the conditions specified in the WHERE statement are true.Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-34558981851813553172009-06-04T16:22:00.003+01:002009-06-04T16:41:27.021+01:00New property syntax in C#3.0Prior to C#3.0 we would use the following syntax for creating properties:<br /><code><br />private string _GetAndSet;<br />public string GetAndSet { get { return _GetAndSet; } set { _GetAndSet = value; } }<br /><br/><br />private string _SetOnly;<br />public string SetOnly{ get { return _SetOnly; } set { _SetOnly = value; } }<br /></code><br /><br />C#3.0 allows us to use the following syntax which is the equivalent of above.<br /><code><br />public string GetAndSet { get; set; }<br/><br />public string SetOnly{ get; private set; }<br /></code>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-27334254543281137162009-06-02T13:08:00.002+01:002009-06-02T13:15:45.021+01:00Create report in Reporting Services 2008<span style="font-weight:bold;">This is a great link to show you how to create reports and deploy them:</span><br /><br />http://www.accelebrate.com/sql_training/ssrs_2008_tutorial.htm<br /><br /><span style="font-weight:bold;">Add a parameter to report once report is created:</span><br /><br />Right click parameter in the report data window - add parameter and fill out required fields.<br />Right click the grid - tablix properties - filters and add in the filter using the parameter as the value.JoJohttp://www.blogger.com/profile/04078157210192367602noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-52947312275686311322009-05-15T11:31:00.002+01:002009-05-15T11:35:41.847+01:00Upload XML FileTo upload an XML file into SQL Server 2008:<br /><br />1. Open SQL Server Business Intelligence Studio.<br />2. Create a new package ( shown in previous post)<br />3. Create Destination table on Server to upload file to.<br />4. Drag on Execute SQL Task - add TSQL to truncate the table.<br />5. Drag on Data Flow Task and double click<br />6. Drag on XML Source file and set the properties.<br />7. Drag on OLE DB Destination and set properties.<br /><br />Job Done.JoJohttp://www.blogger.com/profile/04078157210192367602noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-47387378182267115212009-05-14T16:31:00.002+01:002009-05-14T16:35:00.432+01:00Subsonic Parent -> Child savingHow to save subsonic objects to the db that have FK values needing set.<br /><br />Here's an example that also uses a transaction. Please note that you will have add a reference to the System.Transactions namespace in your project and then reference in your class.<br /><br /><br /><code><br />   using (TransactionScope scope = new TransactionScope())<br /><br />    {<br /><br />        try<br /><br />        {<br /><br />            Order order = new Order();<br /><br />            //populate order details.<br /><br />            order.Save(); //Commit to DB<br /><br /><br /><br /><br /><br />            OrderItem item = new OrderItem();<br /><br />            //populate orderItem details.<br /><br /><br /><br />            item.Order = order;   //THIS LINE SETS THE PARENT OBJECT TO ABOVE ORDER<br /><br /><br /><br />            item.Save();  //Commit to DB<br /><br /><br /><br />            //complete you transaction<br /><br />            scope.Complete();<br /><br /><br /><br />        }<br /><br />        catch (System.Data.SqlClient.SqlException ex)<br /><br />        {<br /><br />            throw ex;<br /><br />        }<br /><br />    }<br /><br /><br /></code>Chrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-68178347167594174512009-05-14T11:42:00.004+01:002009-05-14T11:59:05.206+01:00Create a SSIS packageBasic steps to create an SSIS package (old DTS) to copy data from one database to another in SQL Server 2008:<br /><br />Great link for the basic steps http://it.toolbox.com/blogs/coding-dotnet/creating-a-ssis-package-24699<br /><br />However to truncate the tables before filling them with the above package: <br /><br />1. Drag a Execute SQL Task into the control Flow window. <br />2. Double click and set the connection <br />3. Enter SQL Statement<br />4. Drag green line to the data flow task or the next step to run.<br /><br />Point to Note: This tool is similar to Reporting Services where you create a project and then can have many packages within the project. Each package can then share the connections within the Data Sources folder.<br /><br />Enjoy!JoJohttp://www.blogger.com/profile/04078157210192367602noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-52307770620817791862009-05-08T09:56:00.005+01:002009-05-08T10:11:52.281+01:00Setting up an ASP.Net site for membership using your own database<span style="font-family: arial;font-family:times new roman;font-size:100%;" >If you are setting up a new application and you want to use the membership and roles security then normally .Net will try to set this up for you in your local express server. If however you want to set this up in your application database, on your main server then do the following.<br /><br />1) Run C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe<br />2) Use the wizard to select the server and database. (I believe this can be any of 2000/05/08)<br />3) Change the following in your web config to suit your DB and server settings. Cahnge any other settings to suit your application. Click <a href="http://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx">here</a> for MSDN article.</span><span style="font-size:100%;"><br /></span><pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_mainContentContainer_ctl18other" space="preserve"><configuration><connectionstrings><system.web><authentication mode="Forms"><authorization><span style="font-size:100%;"><code><br /><configuration><br /><br /> <connectionStrings><br /><br /> <add name="MySqlConnection" connectionString="Data<br /><br /> Source=YOURSQLSERVENAME;Initial Catalog=YOURDBNAME;Integrated<br /><br /> Security=SSPI;" /><br /><br /> </connectionStrings><br /><br /> <system.web><br /><br /> <authentication mode="Forms" ><br /><br /> <forms loginUrl="login.aspx"<br /><br /> name=".ASPXFORMSAUTH" /><br /><br /> </authentication><br /><br /> <authorization><br /><br /> <deny users="?" /><br /><br /> </authorization><br /><br /> <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"><br /><br /> <providers><br /><br /> <clear /><br /><br /> <add<br /><br /> name="SqlProvider"<br /><br /> type="System.Web.Security.SqlMembershipProvider"<br /><br /> connectionStringName="MySqlConnection"<br /><br /> applicationName="MyApplication"<br /><br /> enablePasswordRetrieval="false"<br /><br /> enablePasswordReset="true"<br /><br /> requiresQuestionAndAnswer="true"<br /><br /> requiresUniqueEmail="true"<br /><br /> passwordFormat="Hashed" /><br /><br /> </providers><br /><br /> </membership><br /><br /> </system.web><br /><br /></configuration><br /><br /><br /></code><br /><br /><br /></span><span style="font-family: arial;font-family:times new roman;font-size:100%;" ><br />4) That should be you!<br /><br /><br />I got this info by using <a href="http://stackoverflow.com/">StackOverflow</a> and asking this <a href="http://stackoverflow.com/questions/835124/how-do-i-change-my-asp-net-membership-database-from-express-to-standard-sql">question</a>.</span><span style="font-family: arial;font-size:100%;" ><br /></span><br /><br /></authorization></authentication></system.web></connectionstrings></configuration></pre>Chrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-45749254888253838702009-05-07T15:37:00.003+01:002009-05-07T15:42:57.382+01:00Problem with Infragistics Charts in a Web Site!When using Infragistics Chart components in a web site, you may get a <span style="font-style: italic;">GDI+</span> error relating to image permissions.<br /><br />There is an infragistics solution to this problem <a href="http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=5444">here</a>.<br /><br />You have to grant user permissions to the web site folder/virtual directory on the server.<br /><br />Right click the folder > Properties > Security Tab > Add<br /><br />On Windows Server 2003 you would do: <span style="font-style: italic;">servername\NETWORK SERVICE<br /><br /><span style="font-style: italic;">And that should be it.</span><br /></span>Andyhttp://www.blogger.com/profile/05946890717469547713noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-29842006363503492009-05-07T09:10:00.004+01:002009-05-27T11:07:50.548+01:00Calling server side ASP.NET method from jQueryI was recently looking at calling a server side method from an ASP.NET 3.5 application using jQuery. The following example has a server side method that returns some HTML markup from a database to jQuery, which then inserts it into the page markup.<br /><br />Server side code, in Default.aspx:<br /><pre><br /><code><br /><span style="color:#3333ff;">using</span> System.Web.Services;<br /><br />[<span style="color:#339999;">WebMethod</span>(<span style="color:#3333ff;">true</span>)]<br />>(<span style="color:#3333ff;">public static string</span> getMarkup()<br />{<br /> <span style="color:#3333ff;">return</span> "<h3>Test Markup</h3>";<br />}<br /></code><br /></pre><br />You need to make the method static and include the WebMethod(true) operator above it. You can also use the following code to call a WebMethod from an asmx or WCF web service.<br /><br />You call this from the client side jQuery code using:<br /><pre><br /><code><br />$("#loadHome").click(function(){<br /> $.ajax({<br /> type: "POST",<br /> url: "./Default.aspx/getMarkup",<br /> data: "{}",<br /> contentType: "application/json; charset=utf-8",<br /> dataType: "json",<br /> success: function(result){<br /> $("#contentDiv").html(result.d);<br /> }<br /> });<br />});<br /></code><br /></pre><br />This uses the jQuery <a href="http://docs.jquery.com/Ajax">ajax</a> method to get the data from the server side method, which is returned as a <a href="http://www.json.org/">JSON</a> object. You use the .d notation on the JSON object to get the result supplied from the server side.<br /><br />If you want to send any data to the method, send as a JSON object. For example if you had a server side method that takes 2 params, orderId and customerId, you would use:<br /><code><br />var data = "{orderId:'2',customerId:'99'}";<br /></code>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-90709488067435939362009-04-30T08:43:00.001+01:002009-04-30T08:46:59.963+01:00Error On Install: "Installation User Interface Option"I had a problem installing a new version of a windows application, even after I uninstalled all previous versions. I toyed the following steps, but I had to search the registry myself with the produce code form the MSI project in .Net. Just deleted the whole folder once it was found.<br /><br />Here a snippet of the web page I found with the solution:<br /><br /><span style="font-weight: bold;"></span><blockquote><span style="font-weight: bold;">If the application is a Windows or Web application - </span><br /> <br /><span style="font-weight: bold;">1. Go to START, RUN and type the following: MSIEXEC /X "path to the .MSI </span><br /><span style="font-weight: bold;">file you </span><br /><span style="font-weight: bold;">want to uninstall" and click OK. </span><br /><span style="font-weight: bold;">2. After the application is uninstalled, try installing your MSI file </span><br /><span style="font-weight: bold;">again. If you </span><br /><span style="font-weight: bold;">get the same error, then some portion of the application still exists on </span><br /><span style="font-weight: bold;">the </span><br /><span style="font-weight: bold;">machine. You will want to use MSIZAP to remove the product, or you can </span><br /><span style="font-weight: bold;">search for </span><br /><span style="font-weight: bold;">the PRODUCTID of the msi package in the registry and remove the associated </span><br /><span style="font-weight: bold;">registry </span><br /><span style="font-weight: bold;">keys. The Product ID looks like {xxxxx-xxxxx-xxx-xxxxx-xxxxx} </span></blockquote><br /><br />Link to source: <a href="http://www.tech-archive.net/Archive/VisualStudio/microsoft.public.vsnet.general/2005-10/msg00086.html">http://www.tech-archive.net/Archive/VisualStudio/microsoft.public.vsnet.general/2005-10/msg00086.html</a>Chrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-47535670798310468772009-04-29T12:01:00.004+01:002009-04-29T13:06:10.243+01:00Website AccessibilityThere are no set laws in the UK regarding Website Accessibility, but your website should at least meet Priority Level 1 and it is recommended to meet Priority Level 2.<br /><br />Her is the link to Website <span class="blsp-spelling-corrected" id="SPELLING_ERROR_0">Accessibility</span> Level 1 (A) reference:<br /><br /><a href="file:///E:/MUSIC/Justice">http://www.w3.org/WAI/WCAG20/quickref/Overview.php</a>Andyhttp://www.blogger.com/profile/05946890717469547713noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-57109831230757008142009-04-29T11:15:00.003+01:002009-04-29T11:30:39.309+01:00Using multiple versions of browsers (IE + FF)<h2>Internet Explorer</h2><br />I found this handy tool, <a href="http://www.my-debugbar.com/wiki/IETester/HomePage">IETester</a>, for testing your websites in multiple versions of IE, each in a different tab. Currently it can test IE 5.5, 6, 7 and 8 beta. <br /><br />Since it's an early alpha release there is a list of known bugs on their homepage but it is good enough to view pages in.<br /><h2>Firefox</h2><br />I found the easiest way of testing in various versions of FF was to use a portable version since it doesn't need any installation and won't mess with whichever current install you have. <br /><br />You can find all portable legacy versions if FF <a href="http://sourceforge.net/project/showfiles.php?group_id=152554&package_id=168825">here</a>.Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-62894622106259061022009-04-28T11:09:00.003+01:002009-04-28T12:08:57.226+01:00Extension Methods in C# 3.0A new function of C# 3.0 is <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx">Extension Methods</a>.<br /><br />"Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type."<br /><br />For example, if you wanted a method to convert a temperature from celsius to fahrenheit, where previously you would use<br /><code><br /><span style="font-family:courier new;"><span style="color:#333399;">int</span> temp = 30;<br /><span style="color:#333399;">int</span> i = <span style="color:#339999;">myClass</span>.CelsiusToFahrenheit(temp);</span><br /></code><br />using extension methods you can now use<br /><code><br /><span style="color:#333399;">int</span> temp = 30;<br /><span style="color:#333399;">int</span> i = temp.CelsiusToFahrenheit();<br /></code><br />To do this you would create a new static class to contain the static method CelsiusToFahrenheit. The key to extension methods is passing in the <span style="font-family:courier new;color:#333399;">this</span> keyword along with the variable. For example,<br /><pre><br /><code><br /><span style="color:#333399;">public static class </span><span style="color:#339999;">myClass</span><br />{<br /> <span style="color:#333399;">public static int</span> CelsiusToFahrenheit(<span style="color:#333399;">this int</span> temp)<br /> {<br /> <span style="color:#333399;">return</span> (9 / 5) * temp + 32;<br /> }<br />}<br /></code><br /></pre><br />This will now allow you to use the CelsiusToFahrenheit method on any integer variables.<br /><br />You can also add methods to extend your own custom classes, and the methods can have different return types. For example, if you have your own class, TestClass, you can create a static method using extending TestClass, e.g.<br /><pre><br /><code><br /><span style="color:#333399;">public static</span><span style="color:#339999;"> DateTime</span> doSomething(<span style="color:#333399;">this</span><span style="color:#339999;"> TestClass</span> t)<br />{<br /> <span style="color:#006600;">//do something</span><br />}<br /></code><br /></pre><br />Which will then allow you to use:<br /><code><br /><span style="color:#339999;">TestClass</span> t = <span style="color:#333399;">new</span> <span style="color:#339999;">TestClass</span>();<br /><span style="color:#339999;">DateTime</span> x = t.doSomething();<br /></code>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-83493980748099874382009-04-27T13:39:00.009+01:002009-04-27T16:33:37.886+01:00jQuery events not firing for dynamic contentWhen adding dynamic content (using AJAX or DOM modification) using jQuery, events are not fired for the new objects, for example if you have the following html:<br /><code><br /><button id="load" href="#">Test</button><br /><div id="container"></div><br /></code><br /><br />When I click the load button I want to add a link to another page inside the container DIV, so I use the following jQuery.<br /><code><br /><pre><br />$(function() {<br /> $("#load").click(function() {<br /> $("#container").html("<a id='popup' href='contactForm.html'>popup</a>")<br /> });<br /><br /> $("#popup").click(function(){<br /> alert("Clicked");<br /> return false;<br /> });<br />});<br /></pre><br /></code><br />The click event for the dynamically created anchor tag (id="popup") will not fire using the above because this code is run once the document is ready, and at that time jQuery will look for an object with an Id of popup which doesn't exist yet.<br /><br />I've found a few different ways to do this:<br /><br />1. Add a generic click event for the body tag and check what was clicked, for example:<br /><code><br /><pre><br />$("body").click(function(e){<br /> var target = $(e.target);<br /> if (target.is("#popup")) {<br /> alert("Clicked");<br /> return false;<br /> }<br />});<br /></pre><br /></code><br />Using this example you check what was clicked using target.is(), you can use any valid CSS selector statements to check the item clicked. This way is simple to implement but can quickly grow if you have a lot of dynamic content.<br /><br />2. Use the <a href="http://docs.jquery.com/Events/live">live command</a>, which will tell jQuery to bind any current and future references of "#popup" to the click event.<br /><br /><code><br /><pre><br />$("#popup").live("click",function(){<br /> alert("Clicked");<br /> return false;<br />});<br /></pre><br /></code><br /><br />The following 3 ways are variations on the same theme in that the events are bound after content creation.<br /><br />3. Use the jQuery <a href="http://docs.jquery.com/Events/bind">Bind command</a> to bind the click event to a particular function on creation. e.g.:<br /><code><br /><pre><br />$("#load").click(function(){<br /> $("#container").html("<a id='popup' href='contactForm.html'>popup</a>").bind('click', loadClick);<br />//can also use<br />//$("#container").html("<a id='popup' href='contactForm.html'>popup</a>").click(loadClick);<br />});<br /><br />function loadClick(){<br /> alert("Clicked");<br /> return false;<br />}<br /></pre><br /></code><br />4. Insert the function for handling the click event within the initial click event when you create the popup link. This runs the event binding as soon as the item is added.<br /><code><br /><pre><br />$("#load").click(function(){<br /> $("#container").html("<a id='popup' href='contactForm.html'>popup</a>");<br /> $("#popup").click(function(){<br /> alert("Clicked");<br /> return false;<br /> });<br />});<br /></pre><br /></code><br />5. Similar to the above method except this way you create a method which does all data binding (bindEvents()). This can be useful if you have a lot dynamic content that needs to be bound at the same time, it can be encapsulated into 1 event.<br /><code><br /><pre><br />$("#load").click(function(){<br /> $("#container").html("<a id='popup' href='contactForm.html'>popup</a>");<br /> bindEvents();<br /> });<br /> <br />function bindEvents(){<br /> $("#popup").click(function(){<br /> alert("Clicked");<br /> return false;<br /> });<br />};<br /></pre><br /></code><br /><br />There's also a plugin called <a href="http://docs.jquery.com/Plugins/livequery">livequery</a> that makes binding easier.Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com7tag:blogger.com,1999:blog-7192236668889672798.post-91485644144354257322009-04-26T15:57:00.002+01:002009-05-07T10:42:57.145+01:00Firebug for all browsers!When designing websites I've found <a href="https://addons.mozilla.org/en-US/firefox/addon/1843">firebug</a> for FireFox invaluable for checking out exactly what's going on. I've now found you can get <a href="http://getfirebug.com/lite.html">Firebug lite</a> for use on any browser!<br /><br />It's very easy to use, all you have to do is include the following code in any page that you want to use it in:<br /><pre><script type="'text/javascript'" src="%27http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js%27"></script></pre><br />Genius.Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-34663735851505175692009-04-09T10:29:00.001+01:002009-04-09T10:31:39.347+01:00jQuery Intellisense for Visual StudioThe mighty Guthrie explains all....<br /><br /><a title="blocked::http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx" href="http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx">http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx</a>Chrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-30024453033733174172009-04-01T16:47:00.002+01:002009-04-01T16:52:33.102+01:00TSQL script to loop round all databasesHi Guys<br /><br />Quick script to loop round all databases and perform an action - in this case its setting all databases to simple recovery. The keyword here is sp_msforeachdb - pure genius :) <br /><br />use master<br />GO<br />sp_msforeachdb '<br /> declare @sql VARCHAR(1000)<br /> IF DATABASEPROPERTYEX(''?'', ''Rjavascript:void(0)ecovery'') <> ''SIMPLE''<br /> begin<br /> set @sql = ''ALTER DATABASE ? SET RECOVERY SIMPLE''<br />PRINT @sql<br /><br /> end'JoJohttp://www.blogger.com/profile/04078157210192367602noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-72086713885538325682009-03-29T11:12:00.002+01:002009-03-29T11:19:56.578+01:00Using keywordWhen using anything that implements IDisposable (SqlDateReader, SqlConnection etc) you can use the <span style="font-family:courier new;color:#3333ff;">using</span> keyword to ensure that the object is disposed, e.g.<br /><pre><br /><span style="font-family:courier new;"><span style="color:#3333ff;">using</span> (<span style="color:#339999;">SqlDataReader</span> reader = <span style="color:#339999;">Dal</span>.ExecuteReader(GetConnection(), <span style="color:#990000;">"SelectProductAll"</span>))<br />{<br /> dsScrum.ProductTask.Clear();<br /> <span style="color:#3333ff;">if</span> (reader.HasRows)<br /> dsScrum.Product.Load(reader);<br />}</span><br /></pre><br /><br />Is the same as:<br /><pre><br /><span style="font-family:courier new;"><span style="color:#339999;">SqlDataReader</span> reader = <span style="color:#339999;">Dal</span>.ExecuteReader(GetConnection(),<span style="color:#990000;">"SelectProductAll"</span>);<br /><span style="color:#3333ff;">try</span><br />{<br /> dsScrum.ProductTask.Clear();<br /> <span style="color:#3333ff;">if</span> (reader.HasRows)<br /> dsScrum.Product.Load(reader);<br />}<br /><span style="color:#3333ff;">finally</span><br />{<br /> <span style="color:#3333ff;">if</span> (reader != <span style="color:#3333ff;">null</span>)<br /> reader.Dispose();<br />}</span><br /></pre>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-52806349797040538032009-03-25T09:51:00.005+00:002009-03-25T17:56:52.426+00:00jQueryI've been looking at using Javascript libraries recently, in order to revamp <a href="http://lesleywilliamson.com">Lesley's site</a> there are a lot out there (Prototype, Mootools, scriptaculous, Dojo, YUI). I've decided to use JQuery as it appears to have the largest following, which means more support, tutorials and extra plugins. It's also easily extensible meaning you can customise and extend.<br /><br />What is it? "jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript." In short, you can get Flash-type effects and general all-round sexiness using only javascript, could be used for cool menus, client side table sorting, tabs, AJAX data/image loading, page manipulation, custom dialog boxes, charts etc.<br /><br />To use you need some understanding of CSS as it uses CSS-style selectors ("li", "#Id", ".class", "a>img" etc) to access elements using jQuery and it appears a lot of the functionality uses CSS to move/position elements.<br /><br />Here are some good links that I've found:<br /><ul><li><a href="http://jquery.com/">Main Site</a></li><br /><li><a href="http://docs.jquery.com/Main_Page">Documentation incl. lots of links</a></li><br /><li><a href="http://docs.jquery.com/Tutorials">Tutorials</a></li><br /><li><a href="http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/">Beginners video tutorial</a></li><br /><li><a href="http://www.ericmmartin.com/simplemodal/">Modal Demo</a></li><br /><li><a href="http://stilbuero.de/jquery/tabs_3/">Tabs Demo</a></li><br /><li><a href="http://www.gmarwaha.com/blog/category/client-side/jquery/">Menu Demo</a></li><br /><li><a href="http://www.filamentgroup.com/lab/creating_accessible_charts_using_canvas_and_jquery">Charts Demo</a></li><br /><li><a href="http://abeautifulsite.net/notebook.php?article=58">File Tree Demo</a></li><br /><li><a href="http://tablesorter.com/docs/">Sortable Table Demo</a></li><br /><li><a href="http://css-tricks.com/revealing-photo-slider/">Photo Slider Demo</a></li><br /><li><a href="http://www.openstudio.fr/jQuery-virtual-tour.html?lang=en">Virtual Tour Demo (Outrageous)</a></li></ul>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-31825773258803641682009-03-24T10:27:00.006+00:002009-03-24T10:45:57.620+00:00SubSonic<a href="http://subsonicproject.com/">SubSonic</a>..... fed up writing boring DAL code? Me neither.. but if you are this may be for you.<br /><br /><a href="http://subsonicproject.com/">SubSonic</a> has several things we would be interested in but the main selling point is that it auto generates a DAL for you. It also has CMS starter site that seems really cool... more on that later.<br /><br />I'm not going to re-write their web site help here; so I recommend you visit their <a href="http://subsonicproject.com/">site</a> and enjoy the videos. Code is available from <a href="http://www.codeplex.com/subsonic">codeplex</a>... their site was a little flaky when downloading so I used that instead.<br /><br />The forums are really good and its been around for a few year now so I think this is something we should all be considering when taking on a new project.<br /><br />Almost forgot the good news (yes folks it gets better!) its.... wait for it...... <a href="http://en.wikipedia.org/wiki/Open_source">OPEN SOURCE!</a><br /><br />EnjoyChrishttp://www.blogger.com/profile/06817275296074067231noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-25402535721531477362009-03-17T12:09:00.003+00:002009-03-17T12:36:53.510+00:00Setup Blackberry demo on standalone PCI recently had to setup a Blackberry demo onto a standalone laptop, the laptop was a clean install before starting.<br /><br />I setup everything on the local computer, including Web Service, as it would not be connected to the internet or network.<br /><br />To setup do the following:<br /><br /><ul><li>Install appropriate .NET Framework.</li><br /><li>Install IIS and run aspnet_regiis -i.</li><br /><li>Install jdk-1_5_0_17-windows-i586-p.exe for use by simulator.</li><br /><li>Install BlackBerry_Email_MDS_4.1.4.exe for MDS simulator to hit network.</li><br /><li>Install BlackBerry_Simulators_4.5.0.55_8700-Vodafone.exe, or whichever simulator is to be used.</li><br /><li>Install SQLServer onto laptop. Use either desktop engine and connect via IP Address and enterprise manager from own computer to create database, or install full developer edition with Enterprise Manager.</li><br /><li>Create new copy of Web Service pointing at (local).</li><br /><li>Create new copy of Blackberry app, only need to change the connection string in the main <webservicename>_Stub class. Use the laptops computer name as you can't use IP Address as it'll be offline and handset can't hit localhost or 127.0.0.1.</li><br /><li>Move new .COD into the installation folder of the handset simulator.</li><br /><li>Go to network connections on laptop and disable all connections (Right Click->Disable). Not sure why but when these are enabled and not connected to network the web service calls are very slow.</li><br /><li>Run the MDS Simulator first and then open up handset simulator. Done!</li></ul><p>I created a batch file to run the MDS and handset simulator:</p><p>@echo off<br />echo Running MDS Simulator...<br />cd C:\Program Files\Research In Motion\Blackberry Email and MDS Services Simulators 4.1.4\MDS<br />call run.bat<br />echo Running 8700 Simulator...<br />cd C:\Program Files\Research In Motion\Blackberry Smartphone Simulators 4.5.0\4.5.0.55 (8700-Vodafone)<br />call 8700-Vodafone.bat<br />pause</p>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-45706185429246444572009-02-11T12:00:00.001+00:002009-02-11T12:04:01.207+00:00Change simulator used in EclipseTo change the simulator the cod file is loaded into when you debug in eclipse (you’ll need the VS plugin installed first as you get more handsets with this):<br /><br /><ul><li>Right click on the project name and select Debug As… -> Debug Configuration</li><br /><li>Select the Simulator tab on the right.</li><br /><li>Click New, and enter a name.</li><br /><li>Click the advanced tab and change the Working Directory to: C:\Program Files\Research In Motion\BlackBerry VS8 Plugin\handheld\simulator</li><br /><li>Now go back to the General tab and you should be able to select which one you want from the Device drop down. e.g. 8700-black.</li><br /><li>If the Device drop down has nothing in it enter the following into the Command Line of the Advanced tab: C:\Program Files\Research In Motion\BlackBerry VS8 Plugin\handheld\simulator\fledge.exe /app=Jvm.dll /session=8700-black /app-param=DisableRegistration /app-param=JvmAlxConfigFile:8700-black.xml /data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A /handheld=8700-black</li></ul>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-32283567495651210922009-01-18T10:30:00.002+00:002009-01-18T10:41:55.538+00:00webdev.webserver errorI got the above error in VS.NET 2008 when running an ASP.NET app. When trying to debug or show in browser the IDE gives the error in the standard "report to microsoft" dialog box followed by the following message "unable to connect to the asp.net development server".<br /><br />To fix this error:<br /><ul><li>Right click on the project in solution explorer.</li><br /><li>Hit F4 for properties (don't right click for properties).</li><br /><li>Change "Use Dynamic Ports" to false and enter a new port number. Use one quite close to the current port number, I used 1080. Default was 1071.</li></ul>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-59071381074264246922009-01-15T16:32:00.005+00:002009-01-16T14:58:57.973+00:00Show Modal form from Background ApplicationTo show a message from within a background application we can’t just use Dialog.alert(); because this will throw errors as the application is not using the Ui thread. Use the following code to launch a message/screen from the app:<br /><br /><span style="font-family:courier new;">Application.<em>getApplication</em>().invokeAndWait(<strong><span style="color:#990000;">new</span></strong> Runnable()<br />{<br /><strong><span style="color:#990000;">public void</span></strong> run()<br />{<br />UiEngine ui = Ui.<em>getUiEngine</em>();<br />Screen screen = <strong><span style="color:#990000;">new</span></strong> Dialog(<span style="color:#3333ff;">"Message"</span>, <span style="color:#990000;"><strong>new</strong></span> Object[]{<span style="color:#3333ff;">"Ok"</span>,<span style="color:#3333ff;">"Cancel"</span>}, <span style="color:#990000;"><strong>null</strong></span>, 0, Bitmap.<em>getPredefinedBitmap</em>(Bitmap.<em><span style="color:#3333ff;">EXCLAMATION</span></em>));<br />ui.pushGlobalScreen(screen, 1, UiEngine.<em><span style="color:#3333ff;">GLOBAL_MODAL</span></em>);</span><span style="font-family:courier new;"><br /></span><span style="font-family:courier new;">String<br />modalResult = ((Dialog)screen).getSelectedValue();<br />}<br />});<br /></span><br />Can change the screen constructor depending on screen required, the above example just gives an Ok and Cancel button. Use the <span style="font-family:courier new;">invokeAndWait</span><span style="font-family:courier new;">()</span> method blocks the current thread and waits for user to click button to give reply.<br /></span>Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0tag:blogger.com,1999:blog-7192236668889672798.post-86227578537909495732009-01-15T16:29:00.001+00:002009-01-15T16:31:15.651+00:00Cannot Find .debug file errorIf you launch the simulator and get the above error it means that the simulator is loaded with the wrong version of the application. Using Browse.. from the dialog box that pops up and selecting the .debug file won’t fix it. <br /><br />Not sure why this happens but the version loaded and the version in the .debug file differ so any changes you make will not be reflected on the simulator. Sometimes this can happen if you have a dialog box open and you try to debug. I also got this error when I had set an icon in the project, I then removed the jpg file from the workspace but did not delete the icon resource and launched the application.<br /><br />You can clear the applications from the simulator and put it back to it’s original state by using the /clear-flash command in the batch file for launching the simulator, located in:<br /><eclipse>\plugins\net.rim.eide.componentpack4.3.0_4.3.0.8\components\samples\<br /><br />I just added this in, ran it once and then removed it. You can leave it in to get a fresh version of the simulator each time but it takes longer to load and simulator will always prompt to use wizard on load. You need to change something in the project and rebuild it before you will see it on the simulator.<br /><br />To view all other commands that can be used in the batch file, navigate to the samples folder and use the fledge /help command.Donaldhttp://www.blogger.com/profile/17320729941562373752noreply@blogger.com0