Domanda

This is my code

public void loadNumberOfAgents() 
{
    string vmpstring = ConfigurationManager.ConnectionStrings["vmpMMProDat"].ConnectionString;
    SqlConnection vmpsqlcon = new SqlConnection(vmpstring);
    SqlCommand vmpCmd = new SqlCommand("SupGetAgentsWithInteractions", vmpsqlcon);

    SqlDataAdapter DAvmp = new SqlDataAdapter(vmpCmd);
    DataSet DSvmp = new DataSet();
    DSvmp.Clear();
    DAvmp.Fill(DSvmp);

    DataTable table;
    table = DSvmp.Tables[0];
    int numberOfAgents;
    Int32.TryParse(table.Compute("Count(*)", "").ToString(), out numberOfAgents);
}

I got this exception

Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier.

on the last line of my code.

When I execute the stored procedure in SQL Server 2005, I got this:

enter image description here

È stato utile?

Soluzione

You can't use * in aggregate in Compute expression. Use the column name from your DataTable.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top