我在access 2007中有以下查询,它使用访问的SQL设计视图给我正确的结果..
SELECT B1.LAYER_TYPE,
B1.LAYER_NAME AS LAYER_NAME,
B2.LAYER_NAME AS RELATED_LAYER_NAME,
B3.LAYER_NAME AS RELATED_LAYER2_NAME,
C.RULE_NAME
FROM (((NCS_RULES_RELATIONS AS A
LEFT JOIN NCS_LAYERS AS B1 ON A.LAYER_ID = B1.LAYER_ID)
LEFT JOIN NCS_LAYERS AS B2 ON A.RELTD_LAYER_ID = B2.LAYER_ID)
LEFT JOIN NCS_LAYERS AS B3 ON A.RELTD_LAYER2_ID = B3.LAYER_ID)
LEFT JOIN NCS_RULES AS C ON A.RULE_ID = C.RULE_ID
ORDER BY B1.LAYER_TYPE;
结果如下:
但是当我尝试使用c#
和oledbconnection
来访问数据表时,最后一行的RULE_NAME字段值会显示奇怪的结果(参见下图)。
我的检索表代码如下:
public DataTable GetTable(string strSelectSQL)
{
if (this.con.State != ConnectionState.Open)
con.Open();
DataTable dt = new DataTable();
DataSet ds = new DataSet();
IDbCommand command = con.CreateCommand();
command.CommandText = strSelectSQL;
command.Connection = con;
IDbDataAdapter da = factory.CreateDataAdapter();
da.SelectCommand = command;
da.Fill(ds);
dt = ds.Tables[0];
con.Close();
return dt;
}
有人可以帮我解决这个奇怪的行为吗?
答案 0 :(得分:2)
似乎一切都很好。我猜您在Rule_name field
中有多行值,如下所示:AnnoFromLine\n\rDimOnLine
。 Datagridview显示多行值,你可以看到和sql设计视图diplaying只是第一行。