I’m very new to ASP.net and have been following a few video tutorials to build a log in page. I successfully created my registration page fine that enters details into my table within the database fine however I can't get my log in page to work =/.I’ve been at this for a few hours and am not sure if any of you can help but it's worth a shot. The IDE I am using is visual studio (latest version). 

I am getting the following error (clicking the image will give a closer view, but you probably already know that): 
[![enter image description here](https://i.stack.imgur.com/JanKO.jpg)](https://i.stack.imgur.com/JanKO.jpg)

the error changes depending on who I try to log on as for example the above error was returned when trying to log in as john, the below error was returned trying to log in as admin. 

[![enter image description here](https://i.stack.imgur.com/6vPf3.png)](https://i.stack.imgur.com/6vPf3.png)

shown below is my code used behind the log in button: 

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration; 

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

}

protected void Button2_Click(object sender, EventArgs e)
{
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
    conn.Open();
    string checkuser = "select count(*) from [Table] where [Login]'" + Loginbox.Text + "'";
    SqlCommand com = new SqlCommand(checkuser, conn);
    int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
    conn.Close();
    if (temp == 1)
    {
        conn.Open();
        string CheckPasswordQuery = "select Password from [Table] where [Login]='" + Loginbox.Text + "'";
        SqlCommand Passcom = new SqlCommand(CheckPasswordQuery, conn);
        string password = Passcom.ExecuteScalar().ToString().Replace(" ","");

        if (password == Passwordbox.Text)
        {
            Session["New"] = Passwordbox.Text; 
            Response.Write("Password is correct");

        }
        else
        {
            Response.Write("Wrong password");

        }
    }
    else {

        Response.Write("User name does not exist");

    }
    }

}

```

Shown below is the form page view, which runs perfectly fine, the error gets returned when the log in button is pressed. 

[![enter image description here](https://i.stack.imgur.com/o2kfW.png)](https://i.stack.imgur.com/o2kfW.png)

Shown below is the table definition: 

[![enter image description here](https://i.stack.imgur.com/tlLwa.png)](https://i.stack.imgur.com/tlLwa.png)

And shown below is the data contained within the table: 

[![enter image description here](https://i.stack.imgur.com/rWUS4.png)](https://i.stack.imgur.com/rWUS4.png)

Thank you all for your time and I appreciate any input any of you have to help solve this.