Hi
Please help with the following.
This is my code:
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Xml.Linq" %>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Data.OleDb"%>
<html>
<head>
<title>Session Page 2</title>
</head>
<body><p>ASP.NET C# session page 2</p>
<p>first name: <%=Session["FirstName"]%></p>
<p>Password: <%=Session["Password"]%></p>
<%
Response.Write(Session["FirstName"]);
Response.Write("Connecting to db");
OleDbConnection Myconnection= null;
OleDbDataReader dbReader = null;
Myconnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\WebSites\WebSite1\besa.accdb");
Myconnection.Open();
string Firstname = Session["FirstName"].ToString();
OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText ="select password from user where username=='" + Session["FirstName"] + "'";
dbReader = cmd.ExecuteReader();
/*
while (dbReader.Read())
{Response.Write(dbReader.GetString(1));}
dbReader.Close();
*/
Myconnection.Close();
Response.Write("end of prog");
%>
</body>
</html>
The error I get is as follow:
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:
Line 24: OleDbCommand cmd = Myconnection.CreateCommand();
Line 25: cmd.CommandText ="select password from user where username=='" + Session["FirstName"] + "'";
Line 26: dbReader = cmd.ExecuteReader();
Line 27: /*
Line 28: while (dbReader.Read())
Thank you!