Archive for May, 2009

ASP.NET Database connection strings in web.config

Sunday, May 17th, 2009

The Connection string contains sensitive data like username, password, IP address of the server. When we place this sensitive data in an .aspx file for a web application or visual basic or C# files, we run the risk of exposing this data to a hacker.

So, we place this code in the web configuration file. Configuration files are used to store information about application settings.

These files are also referred to as Application Configuration Files and provide security to the data contained in them.

We place the connection string in App.config file for windows applications and web.config file for web applications.
-web.config is created automatically by VS.NET when you create any web project.

-When you compile the web application, web.config is NOT renamed or copied to the BIN folder.

-web.config has several default entries in it to support web/IIS configuration & security.

-You can add the <appSettings>section in the web.config and add your key/value pairs in that section.

-You can have separate web.config files for each directory in your web application, in addition to the one in the root. For each web page, by default, system will look for a web.config in the same folder as the page and if not found, then looks in the parent folder. The web.config file with the connection string will have the following content.

  < ?xml version="1.0"?>
  < configuration>
	< appSettings>
		< add key="DatabasePath"
		  value="server=localhost;
		database=FinAccounting;
		Integrated Security=true;"/>
	< /appSettings>
  < /configuration>

For the web.config file to be read, place the following code in your web application as shown below.

  Imports System.Configuration
  Imports System.Data.SqlClient

  Partial Class _Default
    Inherits System.Web.UI.Page

    Dim dbpath As String
	 = ConfigurationSettings.AppSettings("DatabasePath")
    Dim str_sql_user_select As String
	 = "SELECT * FROM AccountsTable"
    Dim comUserSelect As SqlCommand
    Dim myreader As SqlDataReader

    Protected Sub Page_Load
	(ByVal sender As Object, ByVal e As System.EventArgs)
	  Handles Me.Load

        Dim myConnection As SqlConnection
		 = New SqlConnection(dbpath)
        comUserSelect = New
		 SqlCommand(str_sql_user_select, myConnection)
        TextBox1.Text = ""
        TextBox2.Text = ""
        myConnection.Open()
        myreader = comUserSelect.ExecuteReader
        If (myreader.Read = True) Then
            TextBox1.Text = myreader(0)
            TextBox2.Text = myreader(1)
        Else
            MsgBox("You have reached eof")
        End If

    End Sub
  End Class

Windows 7

Friday, May 15th, 2009

Windows 7 is the updated version of the Vista operating system from Microsoft. It was built around feedback from users and has been developed to work with touch screen controls, among other features.

However, because Microsoft isn’t providing technical support for the Beta, I strongly recommend that only experienced computer users sign up. How experienced? At minimum, you should be comfortable backing up a computer, formatting a hard drive, burning an ISO file to DVD, and installing an operating system from scratch. You should also be comfortable troubleshooting problems on your own. If you’ve not used beta software before, please read the warning messages and make sure you know what you’re getting into.

Windows release candidate is available free to everyone form http://www.microsoft.com/windows/windows-7/download.aspx
and is licensed including a free KEY number, which will continue to work until 1st July 2010. After which you will have to remove it.

PLEASE NOTE at this time of writing, there is no easy upgrade from the free RC1 to the full purchaced version of windows 7.


You will have to do a full reinstall sometime before July 2010.

Windows 7 provides an improved task bar and full-screen previews. Jump Lists put the documents you want handy and the ones you’ve used recently a couple clicks away. Desktop enhancements simplify how you work with the windows on your desktop. You’ll have more intuitive ways to open, close, resize, and arrange them. Introduced with Windows Vista, Windows Search helps you find virtually anything on your PC quickly and easily. Windows 7 also makes search results more relevant and easier to understand. Available now, Internet Explorer 8 helps you do what you want online, faster. With Windows 7, you’ll use a single Devices and Printers screen to connect, manage, and use whatever printers, phones, and other devices you have on-hand.

Crisp, clean, speedy, and highly-usable: It’s the Windows 7 release candidate!
This is possibly the best release of windows ever.

 

Windows 7

In general terms, we can already see major improvements. Looked at across the span of these two preceding releases, the Windows 7 RC is a shining star of performance, usability, stability, and maturity. Yes, there are teething pains, bits of inconsistency that will drive purists nuts (for example, Microsoft can’t seem to settle on a single spelling or capitalization scheme for the HomeGroup feature).

But Windows 7, in release candidate guise, is already a towering achievement that casts Windows Vista immediately in its shadow. I’ve often opined that the true measure of any OS is how painful it renders using its predecessor. And now, several long months after moving to Windows 7 full time, I can honestly state that Windows 7 makes Windows Vista look like a bad dream by comparison. Among many other things, Vista is sluggish compared to 7, and it doesn’t remember window sizes and customization styles. (Windows XP, which lacks so many Vista/7-era features that it’s painful to even discuss, fares even worse by comparison, except in the performance category.)

 

So here we are on the cusp of a new Windows. A Windows that is faster than its predecessor and runs just fine on low-end netbook hardware. It’s more compatible with both hardware and software, especially when you factor in the exciting new XP Mode feature. It’s more secure and reliable. And, most important from an end user perspective, it’s more usable. Now, more than ever, it seems like Microsoft has examined every single nhook and cranny in this OS and has tweaked and gussied up virtually all of it. Some of the user experience changes, like the new taskbar, are immediately obvious on first boot, while other more minor changes simply become apparent over time in the using. There’s a happy change around every corner, it seems.

 

This, then, is the Windows 7 release candidate. And while Microsoft continues to promise only that it will ship Windows 7 sometime by early 2010, I’m here to tell you that Microsoft’s public schedule is almost comically conservative. The Windows 7 RC could literally ship as the final version of the product. There are mitigating factors that will prevent that from happening–persistent rumors of a new UI skin among them–