string strSql = "select id from ComputerAd order by id desc";
SqlCommand LoadCMD = new SqlCommand(SqlLoad, MyConnection);
SqlDataAdapter adapter = new SqlDataAdapter(SqlLoad,MyConnection);
adapter.SelectCommand = LoadCMD;我想问一下 怎么把第一行的id值 取出来
然后付到 int id上去 谢谢
SqlCommand LoadCMD = new SqlCommand(SqlLoad, MyConnection);
SqlDataAdapter adapter = new SqlDataAdapter(SqlLoad,MyConnection);
adapter.SelectCommand = LoadCMD;我想问一下 怎么把第一行的id值 取出来
然后付到 int id上去 谢谢
解决方案 »
- 如何实现像新浪微博在文本框实现@就有好友出现
- vs2008中发布网站后,,生成--发布网站后如何配置?
- 在web页面中调用用户控件
- 求一存储过程
- baal 寻找 “陕西省延安市吴起县 Webdiyer”问: AspNetPager60src 有关问题
- 实现购物车
- 继承Mustinherit类的页面无法用vs2003的编辑器打开?
- 下载了一个论坛源码,可是没有.sln和项目文件,不知道如何打开整个项目??
- 打印顺序问题[各位高手救急]
- Infragistics NetAdvantage 2006 v3 clr2.0 怎样注册啊?
- 在不知道表名的情况下,怎样将一个Access数据库的表名给读出来?
- 在使用System.IO.FileStream读取文件时,显示只找到某文件的路径的一部分.
SqlCommand LoadCMD = new SqlCommand(SqlLoad, MyConnection);
SqlDataReader reader = LoadCMD.ExecuteReader()
while(reader.Read())
{
id = (int)reader["ID"];
}
reader.Close();
MyConnection.Close()
string strSql = "select id from ComputerAd order by id desc";
SqlDataAdapter adapter = new SqlDataAdapter(strSql,MyConnection);
MyConnection.Open();
adapter.Fill(ds,"ComputerAd");int id = Convert.ToInt32(ds.Tables["ComputerAd"].Rows[1]["id"]);部分语法再检查一下
好象不对啊
怎么改都报错
ds.Tables["ComputerAd"].Rows[0].toString() 错误:“ds.Tables["ComputerAd"].Rows”不存在
老大们 不对啊 痛苦中。。
selectCMD.CommandTimeout = 30;SqlDataAdapter custDA = new SqlDataAdapter();
custDA.SelectCommand = selectCMD;nwindConn.Open();DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");nwindConn.Close();上面是填充ds的例子取数据之前,判断ds是否为空
if (DS != null && DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
{
int id = Convert.ToInt32(DS.Tables[0].Rows[0]["id"]);
}