Skip to main content

Posts

Showing posts from March, 2010

Run a SQL Script at runtime of a C# application

In my previous post I explained how to run a SQL Script using Command prompt. It is bit difficult. So I found a way to run the SQL script using the application. I used it on button click. Here is how I did it. 1.   Create your SQL Script. 2. Add the references below to your C# application using Microsoft.SqlServer.Server; using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; 3. Add the path to your SQL Script string Filename = Path .Combine( Environment .GetFolderPath( Environment . SpecialFolder .MyDocuments) + "\\Configuration\\" , "Create_Database.sql" ); 4. Add the code below to read your SQL Script StreamReader StreamReader;           StreamReader = new StreamReader (Filename); string CreateDBQuery = StreamReader.ReadToEnd(); 5. Create a connection with server & Execute Query string tempConnString= "Data Source=(local);Inte

Find your Computer’s location with Windows 7 and Geosense

Windows 7 introduced the new Sensors and Location platform that would let Windows automatically respond to environmental changes sensed by light, orientation sensors, or GPS chips.  This makes your computer more aware of its surroundings and change itself accordingly.  The location platform is especially interesting, as it brings the potential of automatic location based search and maps to your PC.  Unfortunately, most laptops today are not equipped with GPS chips.  Thanks to Geosense, however, you can still use the location platform. Geosense uses IP lookup, Wi-Fi and Cell tower triangulation, and more to find your location as accurately as possible. Geosense lists itself as a sensor in the Windows Sensors and Locations, so once you’ve installed it, all location-aware applications and services will be able to pickup your location from it.  Please note that Geosense only works on Windows 7 Home Premium and higher, as Windows 7 Starter doesn’t include the Sensors and Locations platf