Monday, September 13, 2010

Build a Script-Only ASP.NET 2.0 Data Editing Page

Webmasters and developers who work with a shared hosting service for their sites know that while they usually provide access to your database via EnterpriseManager or Sql Server Management studio, often times it is useful to have your own separate data access page that allows you to access your database for minor work or checking things, and to be able to do this even from behind a firewall.

While there are some pretty good solutions for this (e.g., the free "Web Data Administrator" reference app), all you really need is a simple page that you can drop into your /admin protected web folder and access from anywhere, without having to rebuild your app and redeploy it.

The page I've put together here requires no building; it is a script-only page with no codebehind file, and a minimal amount of script as well, thanks to the GridView control and the SqlDataSource control for ASP.NET 2.0.

Here's the code - all of it!

     "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/1999/xhtml" > "server">            
"form1" runat="server">
"width: 657px">
"width: 160px"> SELECT COMMAND "TextBox1" runat="server" Width="469px" EnableViewState=true>"width: 3px">
"width: 160px"> UPDATE COMMAND "TextBox2" runat="server" Width="466px" EnableViewState=true>"width: 3px">
"width: 160px"> DELETE COMMAND "TextBox3" runat="server" Width="465px" EnableViewState=true>"width: 3px">
"width: 160px"> GO "Button1" runat="server" Text="Populate Grid" Width="110px" OnClick="Button1_Click" />"width: 3px">
"height: 41px"> Free form SQL:"height: 41px"> "TextBox4" runat="server" Width="469px" Height="144px" TextMode="MultiLine">"width: 3px; height: 41px;"> "Button2" runat="server" Text="Execute" OnClick="Button2_Click" />
"GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" CellPadding="4" ForeColor="#333333" GridLines="None" Width="666px" DataSourceID="SqlDataSource1" EnableSortingAndPagingCallbacks="false" PageSize="5" OnPageIndexChanged="GridView1_PageIndexChanged" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting" > "#990000" Font-Bold="True" ForeColor="White" /> "#FFFBD6" ForeColor="#333333" /> "#FFCC66" Font-Bold="True" ForeColor="Navy" /> "#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> "#990000" Font-Bold="True" ForeColor="White" /> "White" /> "SqlDataSource1" Runat="server" SelectCommand="" UpdateCommand="" DeleteCommand ="" ConnectionString="" />
What the above will give you is a page where you enter in the SELECT, UPDATE AND DELETE command statements, and the Gridview and SqlDataSource take care of the rest - including edit, update, cancel, and paging! Here's an example:



I have also added an additional multiline textbox and button for "Free form SQL". If it is a select, you will get it in the GridView, and if its an update, insert or delete, you'll see the rows affected in the label. In sum, pretty much everything you need for basic database work.

You can download the zip file containing the single db.aspx page here. All you need to do is have the correct connection string in your application's web.config connectionStrings section; there is a sample inside comment markers in the code for the page.

Writing simple ANT build script

This article explains how to write a very basic ANT build script. This does not explain indepth knowledge on building your project using ANT script. But, this writeup will be more useful for the beginners who haben't writen any ANTscript before. Before start writing the script, lets look into how to install the ANT in your machine.

Install Apache Ant

Download the Apache Ant from the link : Download Apache Ant

  • Unzip the files into your machine.
  • Set your system path variable to ANT's bin directory. For example d:/projects/ant/bin"
  • Set the ANT_HOME in your system variables. ANT_HOME should point to your Ant installation directory. For example "d:/projects/ant".
  • Set JAVA_HOME in your system environment variables.
  • Copy tools.jar file into the "JRE/lib" folder.
To test the setup open your command prompt and type as "ant". You will see a message saying
 Buildfile: build.xml does not exist! Build failed 
Set up is done. Let's look into our first simple example program using ANT script.

This example program shows how to create the JAR file after building all the java files.

  
In the above code "sampleProject" is the project name for this prticular build. We are setting base directory as the current directory by just giving .(dot). We are telling the script to start from "jar" target name. The default attribute is used for setting the starting point for the ANTscript.

We call a seperate task as target. We can define as many number of targets inside a build file. If we closely look into the build file, we have many number of targets based its operations. So, ourbuild starts with "jar" target.

Target has depends attribute to indicate, that particular task can be executed only after the certain number of dependencies. In our case, before building the jar file, we have to compile the files. So, jar target calls compile target. That has some dependencies that is executed. Once thebuild is successful, test.jar will be created in the same directory.

build.xml

 































Fix User Account Control-Gadget Conflict

UAC may be decent enough in warning and protecting you of intrusions, but it can also get in the way. One bug in the beta actually turns off your desktop Gadgets if you disable UAC. Here's how you re-enable it.

1. Open the Registry Editor, or regedit.exe. You can search for regedit in the Start Menu.
2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar\Settings
3. Right-click and create a new DWORD (32-Bit) Value called AllowElevatedProcess.
4. Right-click AllowElevatedProcess and click Modify. Set the value to 1. Close the registry editor. Your gadgets should work with UAC off now

Use Windows 7 Problem Steps Recorder to document your problems

This doesn't work 100%, but if you type "Program Compatibility" into the search bar in the Start menu, you'll find a compatibility wizard that helps make older apps work with Windows 7. (Sometimes, you can get to it by right-clicking an application that is having trouble launching.) Once you find your app—which may take a little bit of disk browsing if it's not displaying under the list—you'll choose one of potential issues and which version of Windows it previously worked for. In at least one case, we found that running through this made a non-starting app start up under Win 7, so it's good to know about.

Make Older Programs Work With Windows 7

This doesn't work 100%, but if you type "Program Compatibility" into the search bar in the Start menu, you'll find a compatibility wizard that helps make older apps work with Windows 7. (Sometimes, you can get to it by right-clicking an application that is having trouble launching.) Once you find your app—which may take a little bit of disk browsing if it's not displaying under the list—you'll choose one of potential issues and which version of Windows it previously worked for. In at least one case, we found that running through this made a non-starting app start up under Win 7, so it's good to know about.

Use Windows 7's Troubleshooting Tool

There's actually a tool, in Control Panel, called Troubleshooting. Open it up and you'll see various options like configuring devices, connecting to a network and checking to make sure your sound card works correctly. We won't go through each individual options here, but it's a very good place to start when you've hit a problem, before you turn to Googling.

Use Windows 7's Troubleshooting Tool

There's actually a tool, in Control Panel, called Troubleshooting. Open it up and you'll see various options like configuring devices, connecting to a network and checking to make sure your sound card works correctly. We won't go through each individual options here, but it's a very good place to start when you've hit a problem, before you turn to Googling.

Fix the Installer Bug

If you've been running Windows 7 for a few days and found that you're suddenly unable to install programs, here's how to fix it. It's an MSI installer issue, and all you have to do is open up a command prompt in Administrator mode and type:
reg delete HKLM\SOFTWARE\Microsoft\SQMClient\Windows\DisabledSessions /va /f and press enter.

What are the interesting new features in Windows 7?

Windows 7 has several improvements to improve the “fundamentals”—performance, reliability, security and compatibility—along with improvements to make it quicker and easier to access information on your computer:

Enhancements to the Aero User Interface (UI) helps you organize your open windows and other desktop components for easier and faster access

An enhanced start menu and taskbar puts commonly-used resources within easy reach

Performance improvements made in Windows Vista SP1 continue with Windows 7, including faster boot times and resume from standby

Battery life is extended through improved power management architecture and settings

Search Federation in Windows 7 provides results from multiple computers, servers, and Web sites, and delivers these results ranked by relevance

In addition, Windows 7 helps you better manage and secure your computer infrastructure:

Extend data encryption to removable media. News reports are rife with stories about companies losing control over sensitive information. In some industries, this is an issue with grave legal implications, while in other situations the issue is inconvenience. Regardless, smart compliance policy dictates that sensitive information be safeguarded in the event of a lost or stolen laptop. Further, preventing sensitive information from being removed from corporate resources is a pillar of effective compliance management. Windows 7 includes BitLocker™ technology, first implemented in Windows Vista, which now provides full encryption of all boot volumes on a computer, along with introducing BItlocker To Go that offers data protection on portable storage, such as USB flash drives. In addition, BitLocker Drive Encryption and BitLocker To Go can be managed via Group Policy, placing more control over sensitive information in the hands of the professionals.

Automate routine tasks with powerful scripting. To help IT administrators better maintain a consistent environment and improve personal productivity, Windows 7 includes an updated graphical scripting editor, Windows PowerShell™ 2.0—a powerful, complete scripting language that supports branching, looping, functions, debugging, exception handling, and internationalization.

PowerShell 2.0 has an intuitive, graphical user interface that helps make script generation easier, especially for administrators who are not comfortable in command-line environments.

PowerShell 2.0 supports two types of remoting—fan-out, which delivers management scripts on a one-to-many basis, and one-to-one interactive remoting to support troubleshooting of a specific machine. You can also use the PowerShell Restricted Shell to limit commands and command parameters to system administrators, and to restrict scripts to those who have been granted rights.

PowerShell 2.0, with the Group Policy Management Console (available as a separate download), allows IT professionals to use scripting to manage Group Policy Objects and to create or edit registry-based group policy settings in Windows 7. Similarly, you can use PowerShell to configure computers more efficiently, using richer logon, logoff, startup, and shutdown scripts that are executed through Group Policy.

Create, deploy, and manage images more efficiently. Windows 7 includes several tools to streamline the creation and servicing of the deployment image, and to get users up and running as quickly as possible.

The Deployment Image Servicing and Management (DISM) tool in Windows 7 provides a central place to build and service Windows images offline. With DISM, you can perform many functions with one tool: mount and unmount system images; add, remove, and enumerate packages and drivers; enable or disable Windows features; configure international settings, and maintain an inventory of offline images that contain drivers, packages features, and software updates. Windows 7 also enables the same processes and tools to be used when managing virtual machine (VHD) and native file-based (WIM) image files.

Windows 7 also includes Dynamic Driver Provisioning, where device drivers are stored independent of the deployed image and can be injected dynamically based on the Plug and Play ID of the hardware, or as predetermined sets based on information contained in the basic input/output system (BIOS). Reducing the number of drivers on individual machines reduces the number of potential conflicts, ultimately minimizing setup time and improving the reliability of the computer.

When you are ready to deploy Windows 7, Multicast Multiple Stream Transfer enables servers to “broadcast” image data to multiple clients simultaneously, and to group clients with similar bandwidth capabilities into network streams to permit the fastest possible overall transfer rate while optimizing bandwidth utilization.

Provide better support for client virtualization. Windows 7 delivers a richer experience when users are connected to a virtual desktop—much closer to the experience provides by a native Windows desktop. For example, Windows 7 provides multi-monitor support, bi-directional audio to enable Voice over Internet Protocol (VoIP) and speech recognition applications, and access to local devices, such as printers.

Provide enhanced troubleshooting tools. Windows 7 provides rich tools to identify and resolve technical issues, often by the end users themselves. If a help desk call is unavoidable, Windows 7 includes several features and troubleshooting tools to help speed resolution.

The Problem Steps Recorder allows end users to reproduce and record their experience with an application failure, with each step recorded as a screen shot along with accompanying logs and software configuration data. A compressed file is then created that can be forwarded to support staff to help troubleshoot the problem.

Windows 7 includes a suite of troubleshooting packs, collections of PowerShell scripts, and related information that can be executed remotely by IT professionals from the command line, and controlled on the enterprise basis through Group Policy Settings.

Windows 7 also includes Unified Tracing to help identify and resolve network connectivity issues in a single tool. Unified Tracing collects event logs and captures packets across all layers of the networking stack, providing an integrated view into what’s happening in the Windows 7 networking stack and aiding analysis and problem resolution.

Extend the reach of desktop search. Search Federation in Windows 7 provides out-of-the-box support for searching beyond the user’s computer, including network document repositories, search engines, Web applications and proprietary data stores—all from within the familiar Windows interface. IT professionals can publish important search locations through Group Policy, and can deploy up to five search scopes on user’s computers to help them find the information they need more easily. In addition, Windows 7 desktop search supports the public OpenSearch standard, so with a few minor updates, Web developers can take advantage of existing investments in RSS lists to quickly return results to Windows 7.

Windows 7 Troubleshooting

Windows 7 is an updated version of operating system provided by Microsoft. Windows 7 comes with enhanced features to maximize the speed and performance of your computer. However, there are chances that some errors and problems may occur with Windows 7. It becomes extremely necessary to troubleshoot issues related to Windows 7 in order to ensure that your PC works at its optimal pace.

Call 1877-466-7165 microsoft certified tech experts They provide quick and easy troubleshooting support for all problems associated with Windows 7. We will identify and fix software and hardware compatibility issues, driver errors, synchronization problems, and many more. Our Microsoft Certified technicians will troubleshoot errors that occur while restarting Windows 7, changing screen resolution, upgrading video card, etc. Just give us the green light and we will remotely access your computer through the Internet to troubleshoot problems related to Windows 7 operating system.