Welcome to WindowsClient.net | Sign in | Join

No1 Microsoft Fan

Small Basic – Now with SilverLight

Some very cool news from the Microsoft Small Basic team:

(Quoted from MSDN blog, URL is posted below article)

Monday, March 08, 2010 7:42 PM vijayeg

Small Basic – Now with SilverLight

One Program, Two Platforms!

Did you know that with Small Basic v0.8, you can write a program or a game and have it run identically on both your desktop and the browser?  This makes it super easy to share your games with your friends (even those that may be running a Mac).

In fact it is so easy that you can have your program deployed, hosted and running on a browser with just one click of a button!  So easy that it might actually be the fastest and friction free authoring environment for Silverlight.

Here’s an example.  Take this simple program I wrote, which animates a bunch of balls on screen.

For i = 1 To 100
  balls[i] = Shapes.AddEllipse(10, 10)
EndFor

While "True"
  For i = 1 To 100
    ball = balls[i]
    
    x = Math.GetRandomNumber(640)
    y = Math.GetRandomNumber(480)
    Shapes.Animate(ball, x, y, 2000)
  EndFor 
  Program.Delay(1900)
EndWhile

When you run this program from Small Basic, you’ll see a window like this, running on your desktop:

image

When you are ready to share this program with the world, you simply hit the “Publish” button and voila the program is deployed to a Silverlight hosted website.  Check it out for yourself here: http://smallbasic.com/program/?HNV340

Not only can you see your program run on this website, you can also host it on your own website or blog.  Here’s the HTML code to host this little program on your website:

<object id='sbapp' data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='640' height='480'>
    <param name='source' value='http://smallbasic.com/program/ClientBin/SBWeb.xap'/>
    <param name='onError' value='onSilverlightError' />
    <param name='background' value='white' />
    <param name='minRuntimeVersion' value='3.0.40624.0' />
    <param name='autoUpgrade' value='true' />
    <param name='initParams' value='programId=HNV340' />
</object>

Have fun creating Silverlight apps and games from Small Basic.  And don’t forget to share it with your friends!

http://blogs.msdn.com/smallbasic/archive/2010/03/08/small-basic-now-with-silverlight.aspx



DiscountASP.NET Launches SQL Server Profiling as a Service

DiscountASP.NET announces enhancing our SQL Server hosting with the launch of SQL Server Profiling as a service.

SQL Profiler is a powerful tool that allows the application and database developer to troubleshoot general SQL locking problems, performance issues, and perform database tuning.

With our SQL Profiling as a Service customers can schedule a database trace at a specific time of their choosing and offers a new way to help our customers troubleshoot. For more information, visit: http://www.discountasp.net/sp_sql-profiling.aspx

The DiscountASP.NET Team
http://www.discountasp.net
Innovative Windows Hosting

Get 6 months free when you signup, no setup fee, use this Promo code: WISEMX
As a bonus I’ll help you with anything you need in the forums. :-)
  All the best,
    Mark
http://twitter.com/msftwise



*Free* ASP.NET 4.0 Hosting (beta 2) Sandbox now available!

November 12

*Free* ASP.NET 4.0 Hosting (beta 2) Sandbox now available!

You have been asking for it, and it is finally available; a .NET 4.0 beta hosting sandbox!

Signup is easy, just go to the DiscountASP.NET labs page and follow the link.

The number of accounts on the .NET 4.0 beta server are strictly limited, so if you are interested you should sign up today. This is a public beta, so you do not have to be a current DiscountASP.NET customer to take advantage of the offer. We are including MS SQL2008 space in the sandbox space so you have the opportunity to thoroughly test drive the latest .NET features.

In their press release for the new Visual Studio and .NET Framework, "Microsoft described the next release through the following five focus areas: riding the next-generation platform wave, inspiring developer delight, powering breakthrough departmental applications, enabling emerging trends such as cloud computing, and democratizing application life-cycle management (ALM)."

What? Boy, I don't know, but "inspiring developer delight" sounds good to me. If you are interested in democratizing emerging breakthroughs and trends and riding waves you should probably get on board as well.

Sandbox? Waves? See you at the beach! Or better yet, at http://labs.discountasp.net.

Michael Phillips

DiscountASP.NET




Wow, Excel Q/A article overload

Awesome post today from the Microsoft Excel team…

Adding Every Other Cell in a Column

Today’s author is Bill Jelen, author of 24 books on Microsoft Office Excel. He is a regular guest on TechTV with Leo Laporte and the host of MrExcel.com, which includes more than 300,000 questions and answers about Excel.

Jenny asks "Is there a quick way of adding every other cell ?, I have a column of about 250 cells, and I have to select them manually using Ctrl. Can you help ?"

Jenny, this is a matter of using a little math to remember how to determine if a number is even or is odd, and then translate that into the formula.

The formula
=MOD(A1,2)
would return 0 if the number is even and 1 if odd. If we use instead of A1, the ROW() function, we can know if a particular row is even or odd. Now, suppose you're trying to calculate this formula

=A1+A3+A5+A7+A9 ... etc.
or this one
=SUM(A1,A3,A5,A7...)

=SUM((MOD(ROW(A1:A250)-ROW(A1),2)=0)*(A1:A250))

Remember, this is a CSE Formula, to enter it you must press at the same time Control Shift Enter, instead of just Enter as regular formulas.

You can also use this non-array formula

=SUMPRODUCT((MOD(ROW(A1:A250)-ROW(A1),2)=0)*(A1:A250))

MrExcel provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.
http://blogs.msdn.com/excel/archive/2009/09/24/adding-every-other-cell-in-a-column.aspx

Note: I’ve been a fan of Excel for about 20 years now.
We used it as the data backbone for a Voice Recognition System for Mazda.
That early version of Excel worked great on the networks we designed.
This was all pre-Internet, before SQL Server. Awesome memories.

Microsoft NAV 2009 Auto deployment to Client

Freddy Kristiansen, PM Architect on the Microsoft Dynamics NAV team, just posted an awesome article about a very handy tool you can D/L right now called ComponentHelper.

Scenario:

When you install the RoleTailored Client on a number of clients, you might need to install a number of Client side components as well. This might not sound as too much of a problem when you need to install the client anyway – but lets say you install an ISV Add-on with a live customer, who already have 100 clients install – and now you need to install the objects to the database – AND you need to run to 100 computers and install Client side components.

Yes, you can do this with system management policies, but not all customers are running SMS and it would just be way easier if everything could be handled from the ISV Add-On and the Client Components could be auto deployed.

When doing this – it is still important, that IF the customer is running SMS and decide to deploy the Client Side components through system policies – then the auto deployment should just pick this up and accept that things are Ok.

Read more here…
Auto deployment of Client Side Components

Microsoft spotlight: MVP Deborah Kurata

I’ve been keeping an eye on Deborah’s MSMVPS blog and am amazed.
Deborah is posting some awesome code examples in both C# and VB.

Take a look and be sure to subscribe to the RSS feed for more.

Processing Files Using Anonymous Types

Anonymous Types- An Introduction

Defining Lists of Anonymous Types

Counting Words in a String Using Anonymous Types

Using Linq with Microsoft Word and Excel

DAL- Save Data Using a Stored Procedure

Announcing Sync Framework 2.0 CTP2

Love the new Database features...Awesome!

Announcing Sync Framework 2.0 CTP2

I am extremely happy to announce the availability of Sync Framework 2.0 CTP2 .  Sync Framework 2.0 expands on the capabilities offered by Sync Framework 1.0:

  • Adds features that cater to new scenarios or scenarios that were difficult to support.
  • Reduces the amount of work required to develop providers.
  • Supports more data sources with new built-in providers.

The major new features included in this CTP are:

  • New database providers (SqlSyncProvider and SqlCeSyncProvider)
    Enable hub-and-spoke and peer-to-peer synchronization for SQL Server, SQL Server Express, and SQL Server Compact. Sync Framework automatically creates all of the commands that are required to communicate with each database. You do not have to write synchronization queries as you do with other providers. The providers support: flexible initialization options; batching of changes based on data size; and maintenance tasks, such as metadata cleanup and server database restore. 
  • Custom filters
    Enable a filtered replica to store item data only for items that are in the filter, such as a media storage replica that stores only songs that are rated as three stars or better. As the rating on a song changes, an item might move in or out of the filter. A filter-tracking replica is another replica in the community that can identify which items are in the filter and which have moved in or out of the filter recently. A filter-tracking replica may store item data for items that are not in the filter. Sync Framework supports efficient synchronization between filtered replicas and filter-tracking replicas, and maintains all of the necessary metadata.
  • Improved conflict handling
    Sync Framework added several features in this release that make it easier to handle conflicts. 
    • Constraint conflict handling: Sync Framework now supports constraint conflicts, which are conflicts that violate constraints that are put on items or change units, such as the relationship of folders or the location of identically named data within a file system. A destination provider can report a constraint conflict to Sync Framework, and use Sync Framework components to resolve the conflict and determine how to apply the resolution to the destination replica. 
    • Conflict logging: Sync Framework defines a set of conflict log interfaces and provides components that help manage conflicts in the log. Sync Framework also provides an in-memory implementation of the conflict log interfaces for replicas that do not contain a conflict log. It can be useful to save conflicts in a log so that they can be processed separately from the synchronization session, such as when a user needs to review conflicts and decide how to resolve them. 
    • Last-writer-wins conflict resolution: An application might want to resolve concurrency conflicts (in which an item is updated by more than one replica) by keeping the most recently made change, regardless of where the change was made. Sync Framework supports this resolution option by enabling an application to retrieve the time a change was made on the source and destination replicas. The application can then compare the two times and apply the last change. 
    • Improved simple provider conflict handling: Simple providers include a new set of conflict handling interfaces that make it easier to specify resolution actions for concurrency and constraint conflicts.
  • Data conversion between providers
    In some scenarios, synchronization providers synchronize the same type of data (such as sales data), but the data format that each provider requires is different. To address this scenario, Sync Framework enables you to implement interfaces that convert data to the format that each provider requires. In addition to data conversion APIs that can be used for any type of custom provider, Sync Framework also includes conversion APIs specifically for the file synchronization provider.
  • Change application service
    Sync Framework includes a change applier implementation that most applications use to apply changes to a replica. In this CTP, Sync Framework introduces the change application service, which performs the same actions as the change applier, but in a more granular way. A destination provider that requires greater flexibility than the standard change applier can use the change application service to perform only the set of actions that are required.

For more details please visit the Microsoft download center at:
http://www.microsoft.com/downloads/details.aspx?FamilyID=89adbb1e-53ff-41b5-ba17-8e43a2e66254&displaylang=en

Nina Hu
http://blogs.msdn.com/sync/archive/2009/06/04/announcing-sync-framework-2-0-ctp2.aspx

 

PowerShell and SQL Server 2008

The Msft Scripting Guys rock! ;-)


Hey, Scripting Guy!

 

 

 

 

First of all. . .Did you know you can Email your Microsoft Scripting questions to them? -> scripter@microsoft.com, Subject: "Hey, Scripting Guy!"

Additional Resources

Hey, Scripting Guy! Archive by Category

Hey, Scripting Guy! Archive by Date

Hey, Scripting Guy! Download

Now to the topic at hand. . .

How Does Windows PowerShell Make It Easier to Work with SQL Server 2008?

 

Hey, Scripting Guy! Question

Hey, Scripting Guy! I am a SQL database administrator, and in the past I have enjoyed using VBScript for many tasks related to my computers that are running SQL Server. What capabilities does Windows PowerShell provide to make working with SQL Server 2008 easier?

- OS

SpacerHey, Scripting Guy! Answer

Hi OS,

Ed is neck deep in work for the 2009 Summer Scripting Games. He is sipping a cup of Prince of Wales tea, and listening to some Bach on his Zune (yes, we also suspect Ed gets paid a small remuneration each time he mentions his Zune). Ed has been re-reading his heavily worn limited edition of The Adventures of Tom Sawyer recently (not sure if that fact is relevant or not).

This week we are examining using Windows PowerShell to work with SQL Server 2008. The SQL Server 2008 product page is an excellent starting point. From here, you can download trial versions of the real product and free versions of SQL Server 2008 Express Edition. The Script Center Database Hub is a great place to start examining scripting and working with databases.

Because Ed does not consider himself to be a SQL Server 2008 guru, he decided to pass this question off to Buck Woody, SQL Server Technical Specialist for the Microsoft Corporation. He is a former Program Manager on the SQL Server team and the author of seven books about SQL Server. (Compared to Buck, Ed cannot even find SQL in the dictionary.)

 

Yesterday, we explained that Windows PowerShell is a shell, a set of new commands, and a way to script out tasks. But database assistants are a practical lot and demand more. They already have several tools to work with SQL Server. Why learn an additional tool? Because Windows PowerShell does more than just let you type commands into SQL Server. You have the whole Server Management Objects (SMO) library at your disposal—the same library that SQL Server Management Studio uses. Anything that you can imagine doing in SQL Server Management Studio, you can do with Windows PowerShell—in a script.

Let us start where we left off last time and see what we can do with this newly found power. Remember that we learned how to load the SMO libraries, and then we learned how to connect to a server and reference it as a variable:

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
$sqlServer = new-object ("Microsoft.SqlServer.Management.Smo.Server") "(local)"

Now we have a connection to a SQL Server object, and we can do a lot with that simple variable. We can see all the actions we can perform (known as methods) and the attributes we can list or set (known as properties) of the database object by using variables, piping, and the commands from Windows PowerShell:

$sqlServer | 
get-member | 
MORE

As you page down the screen, you might notice a property or two that would be useful to have. One of them is the number of processors installed and usable by SQL Server. With the SQL Server Instance declared as a variable, we can just ask for that by putting a period after the server name and then adding the property we want to see:

$sqlServer.Processors

That is very cool. We can ask about other properties additionally, such as whether the Instance is running:

$sqlServer.Status

To this point, we have been working with the SQL Server Instance. However, because this is the SMO library, we actually have access to almost everything in SQL Server. Let us say that you are interested in the databases on the Instance. This is somewhat different from what we have done already. You see, the things we have asked for have all been a single value—a property on the Instance in this case. The SMO library has not only a single object such as an Instance that you can work with. But those objects can hold other objects. The Status property we asked for is an example of that. But some objects have multiple children underneath them called collections, and you can tell them by their names. The objects that hold even more objects have an “s” at the end of the name, at least most of the time (Processors is an exception, for example). The databases that the Instance holds are a collection because there are other databases underneath it.

To access the objects in a collection, we can use brackets and the number that refers to it, such as this:

$sqlServer.Databases[0].Size

That is somewhat useful, but there is no real way to tell which database this is. Luckily, Windows PowerShell can also take the name of the database in quotation marks for a more friendly display, such as this:

$sqlServer.Databases[“Adventureworks”].Size

That is better. And what can we see about databases, or any object, for that matter? Well, we can turn back to our old friend, Get-Member:

$sqlServer.Databases | get-Member

But what if an object holds even more objects? For example, an Instance has databases, which have tables. How can we see a property there? Simple. We just keep adding those child objects. In this case, even a table is a collection because it holds columns and so on. Here is an example. Let’s discover how many rows are on a table:

$sqlServer.Databases[“Adventureworks”].Tables[“AWBuildVersion”].RowCount

(By the way, this command works because my default schema is dbo together with this table. More about how to browse other schemas later)

But let us say we want to go even further. We would like to examine all the tables and show the row counts. For that, we will have to use another Windows PowerShell feature: functions. A function in Windows PowerShell is exactly like functions in other languages: It is just the name of the function followed by some parameters usually wrapped in a pair of parentheses. In this case, we want to get information about a group of items. We must have a function that reads a group of items and does work on each item in the group. In Windows PowerShell, we have the foreach function. This is followed by any instructions we want.

The interesting thing is that Windows PowerShell does not require us to set up a variable to walk through the list of items like many other languages. Here is what the format of that command resembles:

forEach (BrandNewVariable in SetOfObjects) {do some work} 

Let us put that to work. We’ll use the forEach() function together with our database reference variable ($sqlServer), the AdventureWorks database, and the tables object to list out all the names:

forEach ($table in $sqlServer.Databases["AdventureWorks"].Tables) {$table.Name}

Now let us add the row counts to the previous command. To do this, we query the rowcount property from the table object:

forEach ($tables in $sqlServer.Databases["AdventureWorks"].Tables)`
 {$tables.Name + ": " + $tables.RowCount}

I think that you have the idea. We have now created a variable connection to a SQL Server object or two, and we can do a lot with that simple variable. We can see all the actions we can perform with that Get-Member cmdlet:

$sqlServer.Databases | get-member | MORE

We have been playing around with the properties on the object. So far, we have been just reading them. But many properties can be set equally. This we can see in the second column of the output. Let us change one of the properties on a sample database. Let us change the AutoShrink setting. In this example, we will see the current value, turn it on and then off again:

Note: We cannot tell you how important it is to do this on a testing database, on a testing system. This test system must be something that you do not mind losing, and that no one else is using. No, this should not hurt anything, but our houses should be worth what we paid for them. But they are not. So stop if you are not on a test system.

$sqlServer.Databases["AdventureWorks"].AutoShrink
$sqlServer.Databases["AdventureWorks"].AutoShrink = 1
$sqlServer.Databases["AdventureWorks"].AutoShrink
$sqlServer.Databases["AdventureWorks"].AutoShrink = 0
$sqlServer.Databases["AdventureWorks"].AutoShrink

Of course, this is a fairly simple thing to do. Set a property here and there. How about something that is somewhat more interesting, such as scripting a database? First, let us see whether there is a method (an action) we can perform on the database that sounds somewhat like scripting:

$sqlServer.Databases | 
get-member | 
MORE

There it is in the S’s: Script! Could it be this simple?

$sqlServer.Databases[“AdventureWorks”].Script()

Now, that is just too cool. Hey—we wonder if we could script out multiple databases. Let us use that same loop we tried earlier and see whether we can use it to script out all the databases:

forEach ($database in $sqlServer.Databases) {$database.Script()}

But of course, we need a way to save all this. We can use another cmdlet that is known as Out-File. That cmdlet creates a file on the hard disk, and it has several switches that you can see with the Get-Help cmdlet. All we have to do is add a piping command to the “work” section of our loop, and then we can send each object, one at a time, to a file. Here is an example that bundles up all the database scripts into a single file that is named c:\temp\Scripts.sql:

forEach ($database in $sqlServer.Databases) {$database.Script() |`
 out-File –Filepath c:\temp\Scripts.sql -Append}

But let us say we want to retrieve all the tables in a particular database scripted, instead of just the database itself. We can use another loop to do that. (Warning, this might take some time to run! You can press CTRL+C if you want to stop the script.)

forEach ($tables in $sqlServer.Databases["AdventureWorks"].Tables)`
 {$tables.Script()}

All we are doing there is walking through the table objects on the database and sending them to the scripting object. But moving through the SMO object model does have some challenges. As you work through these examples, you will undoubtedly encounter them. Can Microsoft just make this a bit easier? Sure, we can. And next time we will show you what we have done. We cannot wait!

 

Once again, Buck has hit a home run. Oh, yeah, Ed's Bach prelude is complete, and his tea pot is empty. He has written an absolutely dastardly event for the 2009 Summer Scripting Games. He smiles a crooked little grin and does a passable imitation of Dr. Evil. The Summer Scripting Games will be awesome. Thank you for writing, OS, and join us tomorrow as Windows PowerShell with SQL Server 2008 Week continues. Until then, stay safe. For the latest information about the Summer Scripting Games, follow us on Twitter.

 

Ed Wilson and Craig Liebendorfer, Scripting Guys
http://www.microsoft.com/technet/scriptcenter/resources/qanda/may09/hey0527.mspx

Page view counter