Hi all.

i have a trouble of my testing project. could anyone can guide me to solve the problem. million thanks~~ newbie of programming.

error : System.Data.SqlClient.SqlException: 'Incorrect syntax near 'card'.'

string connectionstring = ConfigurationManager.ConnectionStrings["library2ConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(connectionstring);

        con.Open();

        string sql = "Select librarycardid, password" + 
            "from library card information" +
            "where librarycardid = '" + librarycardid + "'" + 
            "and password = '" + password + "' ";

        SqlCommand cmd = new SqlCommand(sql, con);
        SqlDataReader reader = cmd.ExecuteReader();  <<<<<<error at here 

        if (reader.HasRows)
        {

            Label3.Text = " login success";
        } else {
           Label3.Text = "login fail";
        }

con.Close();

string sql = "Select librarycardid, password" + 
        "from library card information" +
        "where librarycardid = '" + librarycardid + "'" + 
        "and password = '" + password + "' ";

There is no space between password and from, information and where, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.