Please help with the follwing:
This is my testpassword.aspx file:
Expand|Select|Wrap|Line Numbers
- <%@ 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("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();
- 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>
Expand|Select|Wrap|Line Numbers
- 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 23: OleDbCommand cmd = Myconnection.CreateCommand();
- Line 24: cmd.CommandText ="SELECT password FROM user WHERE username='"+Session["FirstName"]+"' ";
- Line 25: dbReader = cmd.ExecuteReader();
- Line 26: while (dbReader.Read())
- Line 27: {
- Source File: c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\WebSites\WebSite1\testpassword.aspx Line: 25
Thank you for any help and advise.