I'm new to SQL and visual studio etc. but I've changed something that isn't allowing me to login to my application. Whenever I press the login button I get this error
Incorrect syntax near the keyword 'from'
Here is where the source may be;
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;
namespace RockPaperApp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["New"] != null)
{
Response.Redirect("/Game.aspx");
}
}
protected void RegButton_Press(object sender, EventArgs e)
{
Response.Redirect("/Register.aspx");
}
protected void LogButton_Press(object sender, EventArgs e)
{
string username = UsernameLogTxt.Text;
try
{
string conn = ConfigurationManager.ConnectionStrings["UserConS"].ToString();
string CommandText = "pword from data Username=@username";
using (SqlConnection connection = new SqlConnection(conn.ToString()))
using (SqlCommand command = new SqlCommand(CommandText, connection))
{
command.Parameters.AddWithValue("@username", username);
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string realpass = reader[0].ToString();
if (realpass != PasswordLogTxt.Text)
{
Response.Write("<span style='color:red'>A Wrong Username of Password has been entered.</span>");
}
else
{
Session["New"] = UsernameLogTxt.Text;
Response.Redirect("/Game.aspx");
}
}
if (!reader.HasRows)
{
Response.Write("No such username exists.");
}
}
connection.Close();
}
}
catch (SqlException ex)
{
Response.Write( ex.Message);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Register.aspx");
}
}
}
postgresql,oracle,sql-server, ...). SQL is a query language, not a DBMS product.