首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DB2 查询 新手轻喷.解决方案

2013-12-20 
DB2 查询 新手轻喷...我要从一个表中去数据。比如表A里边的结构是这样IDabcd1... ... ... ...2... ... ...

DB2 查询 新手轻喷...
我要从一个表中去数据。
比如表A
里边的结构是这样
ID   a   b   c   d
1   ... ... ... ...
2   ... ... ... ...
3   ... ... ... ...
.   ... ... ... ...
.   ... ... ... ...
.   ... ... ... ...
我的代码如下
string connstr = string.Format("Database=MMM;Server=192.168.11.11:50000;User ID=ddd;Password=ddd");
DB2Connection db2 = new IBM.Data.DB2.DB2Connection(connstr);
DB2Command db2com = new DB2Command("select * from A where ID ???", db2);
db2.Open();
DB2DataReader dr = db2com.ExecuteReader();
while (dr.Read())
{
    string a = dr["a"].ToString();
    string b = dr["b"].ToString();
    string c = dr["c"].ToString();
    string d = dr["d"].ToString()
}
ID一共多少并不确定。我这样写好像只能把ID写死。
求高手帮我解决下...
刚刚接触DB2
如果方便 稍微写一下Sql语句 容易理解点
谢谢大家了!!!

如果想要全部表的内容就不要加where语句 

热点排行