|
-
February 22nd, 2011, 07:52 PM
#1
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|