I am using Microsoft visual web developer 2008 Express edition / asp.net / C#
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.Data.Sql;
using System.Configuration;
using System.Data;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RUWSportCenterConnectionString2"].ConnectionString);
SqlDataAdapter sda = new SqlDataAdapter("select * from Registration where User name = '"+ TextBox1.Text +"' and Password = '"+ TextBox2.Text +"'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count == 1)
{
Label6.Visible = false;
Response.Redirect("ViewPro.aspx");
}
else
{
TextBox2.Text = "";
Label6.Text = "Check your USER NAME or PASSWORD";
Label6.Visible = true;
}
Khargesh RajputPosted Apr 30, 2015, 12:08 AM
user name is not your column name
there should not be space
check it
Syed ShanuPosted Apr 29, 2015, 8:35 PM
are your sure in your table also you have the space check for the column name and correct it.
SqlDataAdapter sda = new SqlDataAdapter("select * from Registration where User name = '"+ TextBox1.Text +"' and Password = '"+ TextBox2.Text +"'", con);
If in your table you have the space then change the query like this
SqlDataAdapter sda = new SqlDataAdapter("select * from Registration where [User name] = '"+ TextBox1.Text +"' and [Password] = '"+ TextBox2.Text +"'", con);
Alshifa AbdulrahmanPosted Apr 29, 2015, 8:26 PM
Sda.Fill(dt);
The error is:
An expression of non-boolean type specified in a context where a condition is expected, near 'name'.
I want to check the user name and password with the sql database to login
Syed ShanuPosted Apr 29, 2015, 8:19 PM