使用查询填充数据网格时出错

时间:2012-10-13 09:31:39

标签: c# sql-server-2008

我有一个DataGridView并且我将此查询添加到此处,执行时我的查询会抛出此错误:

  

新查询返回的架构与基本查询

不同

我的查询:

        SELECT
               B.SettingKey, 'SysSettingsDep' AS TableName,
               B.SettingValue, B.SettingDesc
        FROM   SysCustomer AS A INNER JOIN
               SysSettingsDep AS B ON A.SettingKey = B.SettingKey
        UNION
        SELECT C.SettingKey, 'SysSettingsMachine' AS TableName,
               C.SettingValue, C.SettingDesc

        FROM    SysCustomer AS A INNER JOIN
                SysSettingsMachine AS C ON A.SettingKey = C.SettingKey
        UNION
        SELECT  D.SettingKey, 'SysSettings' AS TableName,
                D.SettingValue, D.SettingDesc
        FROM    SysCustomer AS A INNER JOIN SysSettings AS D ON
                A.SettingKey = D.SettingKey

帮我解决这个问题,

tnx

1 个答案:

答案 0 :(得分:0)

最有可能看起来最初创建的TableAdapter / DataTable使用了不同的查询(基本查询),而您使用的新查询似乎正在获取不同的结果模式,从而导致不匹配。

尝试为您的DataSet使用新的TableAdapter,而不是旧的.... / / p>