Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Jul 01, 2010 @ 11:42
    Tom Madden
    0

    Anyone else get SQL errors with User.getAllByEmail ?

    I'm working on using a front end form to create some content nodes and am gettign a SQL error when trying to retreive the member using their email. I'm using this line:

    Snippet

    User[] authors = User.getAllByEmail(_email);

    But I get the following error:

    Incorrect syntax near '@email'.

    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.SqlClient.SqlException: Incorrect syntax near '@email'.

    Source Error:

    Line 183:            String _email = umbraco.cms.businesslogic.member.Member.GetCurrentMember().Email;
    Line 185: User[] authors = User.getAllByEmail(_email);


    Source File: C:\client sites\GCSS 2010\GCSS Intranet\BlogIntranet Usercontrols\Usercontrols\Create-Post.ascx.cs    Line: 185

    Stack Trace:

    [SqlException (0x80131904): Incorrect syntax near '@email'.]
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394
    System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
    System.Data.SqlClient.SqlDataReader.get_MetaData() +83
    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
    System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +70
    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, String commandText, SqlParameter[] commandParameters, SqlConnectionOwnership connectionOwnership) +77
    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) +102
    umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper.ExecuteReader(String commandText, SqlParameter[] parameters) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\datalayer\SqlHelpers\SqlServer\SqlServerHelper.cs:77
    umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\datalayer\SqlHelper.cs:240

    [SqlHelperException: Umbraco Exception (DataLayer): SQL helper exception in ExecuteReader]
    umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\datalayer\SqlHelper.cs:244
    umbraco.BusinessLogic.User.getAllByEmail(String email) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\businesslogic\User.cs:366
    BlogIntranet_Usercontrols.Usercontrols.Create_Post.btnPost_Click(Object sender, EventArgs e) in C:\client sites\GCSS 2010\GCSS Intranet\BlogIntranet Usercontrols\Usercontrols\Create-Post.ascx.cs:185
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    The email is retrevide through this code and I've stepped through the code and the email is correct

    Snippet

    Member.GetCurrentMember().Email;

    I've changed to:

    Snippet

    User[] authors = User.getAllByLoginName(_login);

    But if anyone else has commens about whether thowks or not, I'll add it to codeplex if anyone else confirms it.

    Thanks

    Tom

  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Jul 01, 2010 @ 11:43
    Tom Madden
    0

    In the post above, I'm using version 4.0.4.1

Please Sign in or register to post replies

Write your reply to:

Draft