0

同じクエリで sqldatasource を使用すると、グリッドビューにデータが表示されない理由がわかりません。

cmd.Connection = conn
    conn.Open()
    cmd.CommandText = "SELECT DISTINCT TOP (100) PERCENT dbo.tblConfig_Agent.FirstName, dbo.tblConfig_Agent.LastName, SUM(dbo.tblData_DeviceByDevice.ACDCount) AS Calls, SUM(dbo.tblData_DeviceByDevice.ACDDuration) AS Seconds, dbo.tblConfig_AgentGroup.Name, dbo.tblConfig_Agent.Pkey FROM dbo.tblData_DeviceByDevice INNER JOIN dbo.tblConfig_AgentGroup ON dbo.tblData_DeviceByDevice.FKDevice2 = dbo.tblConfig_AgentGroup.Pkey INNER JOIN dbo.tblConfig_Agent ON dbo.tblData_DeviceByDevice.FKDevice1 = dbo.tblConfig_Agent.Pkey WHERE     (dbo.tblData_DeviceByDevice.MidnightStartDate BETWEEN '4/10/2011' AND GETDATE())GROUP BY dbo.tblConfig_Agent.FirstName, dbo.tblConfig_Agent.LastName, dbo.tblConfig_AgentGroup.Name, dbo.tblConfig_Agent.Pkey ORDER BY Seconds, dbo.tblConfig_Agent.FirstName, dbo.tblConfig_Agent.LastName"
    da.Fill(ds, "test")


    GridView2.DataSource = ds.Tables("test")
    GridView2.DataBind()
    conn.Close()
    UpdatePanel1.Update()
4

1 に答える 1

2

データセットの充填方法を見直す必要があると思います....

データアダプタ

  // Assumes that connection is a valid SqlConnection object.
string queryString = 
  "SELECT CustomerID, CompanyName FROM dbo.Customers";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);

DataSet customers = new DataSet();
adapter.Fill(customers, "Customers");
于 2011-05-04T13:56:49.760 に答える