I am trying to do SQL injection to oledb connection and I am getting syntax error when I entering value #
.
I can't understand why this is happening because doing: value' or '1'='1
is working.
OleDbConnection Con = new OleDbConnection();
Con.ConnectionString = @"provider=microsoft.ACE.oledb.12.0;data source=" + Server.MapPath("") + "\\database.accdb";
Con.Open();
string sqlstring = "select * from users WHERE myusername = '"+InputUserName.Text+"' AND mypassword ='"+InputPassWord.Text+"'";
OleDbCommand Cmd = new OleDbCommand(sqlstring, Con);
OleDbDataReader dr1 = Cmd.ExecuteReader();
if (dr1.HasRows)
{
dr1.Read();
Response.Redirect("connectionSuccesful.aspx");
}
else
Label1.Text = "not valid username or password";
I also tried: string sqlstring = $"select * from sellers WHERE Myusername = '{InputUserName.Text}' -- AND Mypassword ='{InputPassWord.Text}'";
but it gives me syntax error again. I am using microsoft access database and using oledb reader.