Alex Lozano Alex Lozano - 5 months ago 18
SQL Question

Syntax error in FROM close?

Trying to work on this for a while now, I've gone back and fort on having my own log in page without using the tool of log in, but I prefer on using the Login just because I've used it before.
Anyways I'm getting the error when trying to log in


Syntax error in FROM clause

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in
FROM clause.


Source Error:

is supposedly the
sqlDA.fill(ds.userinfo)
;

Here's the code in my class

public class clsDataLayer
{

public static dsUser VerifyUser(string Database, string UserName, string UserPassword)
{
dsUser DS;
OleDbConnection sqlConn;
OleDbDataAdapter sqlDA;
// Connects to the DB
sqlConn=new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" +"Data Source=" +
Database);
sqlDA=new OleDbDataAdapter("Select AccessLevel from UserInfo"+
"Where UserName like " + UserName+"' "+
"and UserPassword like '"+UserPassword+"'",sqlConn);
DS= new dsUser();
sqlDA.Fill(DS.UserInfo);
return DS;

}

Answer

Try this

sqlDA=new OleDbDataAdapter("Select AccessLevel from UserInfo"+
           " Where UserName like '" + UserName+"' "+
           " and UserPassword like '"+UserPassword+"'",sqlConn);
Comments