注册 登录
编程论坛 ASP.NET技术论坛

想问一下复值问题

s6gy 发布于 2007-10-23 17:09, 759 次点击


SqlCommand cmd =new SqlCommand("select * from vote1 where public1=1", con);
string title =Convert.ToString( cmd.ExecuteScalar());


表里面有ID TITLE CONTENT 字段
只有一行查询出来 然后我想把这一行的值分别 复给某个怎么处理啊
谢谢帮忙啊 大哥大姐们
7 回复
#2
师妃暄2007-10-23 17:12
SqlCommand cmd = new SqlCommand("select * from vote1 where public1=1", con);
SqlDataReader reader = cmd.ExecuteReader();
int i = Convert.ToInt32(reader[0].ToString());
string title = reader[1].ToString();
string content = reader[2].ToString();
#3
s6gy2007-10-23 17:26
int i = Convert.ToInt32(reader[0].ToString()); 这里的 reader[0]. 是什么意思
是定义一个数组吗?
刚上面的问题如果不是一行呢 是不是写法一样的 麻烦了
刚写还不很明白
#4
s6gy2007-10-23 17:32
并且好象 还有错误

编译器错误信息: CS1502: 与“System.Convert.ToInt32(object)”最匹配的重载方法具有一些无效参数
int i = Convert.ToInt32(reader[0].ToString()); 就这一行还有错误
#5
sxzxwxf222007-10-23 18:04
int i = reader.GetInt32(0);
string title = reader.GetString(1);
string content = reader.GetString(2);
#6
guoxhvip2007-10-23 18:10
reader是SqlDataReader对象
#7
冰彩虹2007-10-23 21:38

基础,基础,注意基础知道啊...

#8
jxnuwy042007-10-24 00:26
建议LZ多看看关于方面的知识.
1