CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Exclamation SQL validated, but causes crash

    Hi all,

    First time poster at CG

    I'm attempting to perform the following query on a database:

    SELECT loginData.userName
    FROM loginData
    INNER JOIN EventAttendance ON loginData.userId = EventAttendance.userID
    WHERE (EventAttendance.eventID = 0)
    ORDER BY loginData.userName

    I created the query in Visual Studio's Query Builder, which validated the syntax as fine, and ran a test execution, which ran perfectly.

    But when I come to use the query (in ASP.NET/C#), it exceptions out with:
    "The multi-part identifier "System.Web.UI.WebControls.DataControlFieldCell" could not be bound."

    I attach my code if you'd like to see it:

    SqlConnection connection = new SqlConnection(CSTRING);
    connection.Open();
    string sqlCommand = "SELECT loginData.userName FROM loginData INNER JOIN EventAttendance ON loginData.userId = EventAttendance.userID WHERE (EventAttendance.eventID = " + eventID + ") ORDER BY loginData.userName";
    SqlDataSource s = new SqlDataSource(CSTRING, sqlCommand);
    DataView d = (DataView)s.Select(DataSourceSelectArguments.Empty);
    for (int i = 0; i < d.Table.Rows.Count; i++)
    {
    message(d.Table.Rows[i][0].ToString());
    }
    connection.Close();

    Please help me CodeGuru, you're my only hope

    Mark

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: SQL validated, but causes crash

    Well - from the error message I'd say it isn't the query which is your problem.
    But try to run it directly on the server to verify the query is correct.

    The error message seems to indicate you have a problem with the .NET control instead. I'd focus on that to begin with, especially if you've checked the query works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured