Wednesday, February 24, 2010

How to Enable Host Based Authentication in PostgreSQL

The PostgreSQL server by default works for localhost and you cannot connect to the server remotely or using ip address. To enable ip or remote connection you have to do the followings:
1. Open the file C:\Program Files\PostgreSQL\8.4\data\pg_hba.conf (Supposing Postgre to be installed in Program Files)
2. Find this text # IPv4 local connections:
3. Find this line "host all all 127.0.0.1/32 md5" line
4. Add this line after the Step 3 line:
host all all 192.168.10.0/24 md5
Supposing that you are the ip series: 192.168.10.x
if you are using 192.168.0.x then the entry might be :
host all all 192.168.0.0/24 md5
5. Reload the congifuration OR restart the server from Start->All Programs->PostgreSQL ->Restart Server

Get Value From Invisible Column in Gridview

Sometimes we want to store any ID in the GridView and not to show to the user. Ok, but problem arises when we want to get the invisible value from the selected row.

Basically, Microsoft have decided that hidden columns in DataGrids were almost always used to store primary keys of records, and that maintaining them in ViewState represented a security risk. Therefore, in the GridView object introduced in v2, hidden columns have been removed from ViewState by default, which is why the columns themselves are still there (otherwise you
couldn't reference them in the CodeFile), but their values are blank.

Fortunately, there is an easy workaround. Simply set the column(s) to Visible immediately before invoking the GridView's DataBind() method, and then hide them again immediately after. E.g.
MyGridView.DataSource =
MyGridView.Columns[x].Visible = true;
MyGridView.DataBind();
MyGridView.Columns[x].Visible = false;

Now you can get the values of all columns after the GridView having selected:

GridViewRow row = gvCodeDetails.SelectedRow;

for (int count = 0; count < row.Cells.Count; count++)
{
Response.Write("Count: " + count + " " + row.Cells[count].Text + "<br />");
}
This code is for getting and displaying all columns of any selected GridView row; you will use that one you need.

It seems good but sometimes it causes problems. I do not find any value of the hidden field, found blank instead. However, here is a rather better way I find to be more effective.

Keep the columns you want to store hidden in the DataKeyNames facility.

if you wan't to hide two columns then you can set multiple columns in the DataKeyNames like:
Write column names separated by comma at the gridview properties DataKeyNames field.

Alternatively you can write manually on the source view

DataKeyNames="Column1, Column2"

then you can access it this way:

string key1 = GridView1.DataKeys[rowIndex].Values[0].ToString(); //first key
string key2 = GridView1.DataKeys[rowIndex].Values[1].ToString(); //second key

In this way you can retrieve the values from the gridview.

Tuesday, February 23, 2010

Error: ASP.NET Not Installed

Error: ASP.NET Not Installed OR some other problem when you install IIS after installing ASP.NET or Visual Studio

This error occurs when ASP.NET is not installed correctly on the computer that you are trying to debug. This might mean that ASP.NET was never installed or that ASP.NET was installed first and IIS was installed later.

To reinstall ASP.NET

  • From a command prompt window, run the following command:

    \WINDOWS\Microsoft.NET\Framework\version\aspnet_regiis -i
where version represents the version number of the .NET Framework installed on your computer, such as v1.0.370. You can determine the framework version by looking in the \WINDOWS\Microsoft.NET\Framework directory.

Monday, February 22, 2010

How to setup svn server in Windows

A) Download Subversion

You'll need the latest version of..

B) Install Subversion

  1. Unzip the Windows binaries to a folder of your choice. I chose c:\program files\subversion\ as my path.
  2. Now, add the subversion binaries to the path environment variable for the machine. I used %programfiles%\subversion\bin\

  3. You'll also need another environment variable, SVN_EDITOR, set to the text editor of your choice. I used c:\windows\notepad.exe

C) Create a Repository

  1. Open a command prompt and type (if environmental variable not works, go to the bin directory through command prompt: #cd\ then #cd %programfiles\subversion\bin )
    svnadmin create "c:\Documents and Settings\Subversion Repository"
  2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd

    Next, uncomment these lines in the /conf/passwd file (You will add the users with password here):

    [users]
    harry = harryssecret
    sally = sallyssecret

D) Verify that everything is working

  1. Start the subversion server by issuing this command in the command window:
    svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"
  2. Create a project by opening a second command window and entering this command:

    svn mkdir svn://localhost/myproject

    It's a standard Subversion convention to have three folders at the root of a project:

    /trunk
    /branches
    /tags

  3. At this point, Notepad should launch:

    Enter any comment you want at the top of the file, then save and exit.
  4. You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:

    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Password for 'Administrator': *********
    Authentication realm: 0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Username: sally
    Password for 'sally': ************

    Committed revision 1.

    Congratulations! You just checked a change into Subversion!

E) Start the server as a service

  1. Stop the existing command window that's running svnserve by pressing CTRL+C.
  2. Copy the file SVNService.exe to the subversion\bin folder.
  3. Install the service by issuing the following commands:
    svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
    sc config svnservice start= auto
    net start svnservice
  4. Test the new service by listing all the files in the repository:
    svn ls svn://localhost/

    You should see the single project we created earlier, myproject/

F) Set up the shell extension

  1. Run the TortoiseSVN installer. It will tell you to restart, but you don't need to.
  2. Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."



    type svn://localhost/myproject/ for the repository URL and click OK.


  3. Create a new file in that directory. Right click the file and select "TortoiseSVN, Add"


  4. The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit":

And we're done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690.

Thursday, February 18, 2010

How to read Yahoo Mail in Gmail

Lately, lots of people want to switch from Yahoo Mail to Gmail because of the great features provided by Google. Yahoo does a good job at not letting this happen by not offering POP and forwarding to their free accounts. If you want to read you Yahoo Mail in Gmail or even to switch completely to GMail, read further.

To read your Yahoo Mail in GMail you have to follow these two simple steps:

1. Activate POP 3 and mail forwarding in Yahoo Mail.

To activate POP 3 access and mail forwarding for your free Yahoo Mail account, follow this tutorial.

2. You can choose one of these two options:

  • use mail forwarding: Go to Yahoo Mail, in the select Options, Mail Options (from the upper right corner of the windows in the new Yahoo Mail interface). Then, go to the POP and Forwarding screen and activate forwarding, sending the mail to your GMail address.
  • use POP3: GMail features automatic mail fetching using POP3. Go to Settings, Accounts in Gmail. Then, from the zone called “Get mail from other accounts”, click on Add and enter the information provided in the following screenshot. You can apply a label to incoming mail and the other settings are already set your your convenience in the GMail interface.

Using POP, your mail will be fetched hourly and this cannot be changed, so if you need fast response time, choose the forwarding solution. The POP3 has the advantage that you can move your existing emails in GMail so that you can benefit from labels, better search and the other features of GMail. The choice is yours.

You can also configure GMail so that you can send mails from GMail and appear that you are sending from your Yahoo address. To do this, you should click the Settings button, then Accounts (in the GMail interface). From the “Send mail as” zone, click “Add another email address you own” and follow the wizard. You will have to reply to an email sent to your yahoo address and that’s about it. You can switch from using Yahoo to Gmail completely using these tips. Enjoy!

Thanks to Picobit