C#后台 给(dataset)ds添加一列并赋值,总说我(红色区域)输入字符串的格式不正确

lc12d 2009-07-05 11:41:22
DataColumn filepath = new DataColumn("filepath", Type.GetType("System.String"));
filepath.AutoIncrement = true;
filepath.AutoIncrementSeed = 0;
filepath.AutoIncrementStep = 1;
ds.Tables["news"].Columns.Add(filepath);

for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
if (ds.Tables["news"].Rows[i]["content"].ToString().Length > 11)
ds.Tables["news"].Rows[i]["filepath"] = ds.Tables["news"].Rows[i]["content"].ToString().Substring(0,11)+"..."; else
ds.Tables["news"].Rows[i]["filepath"] = ds.Tables["news"].Rows[i]["content"].ToString();

}


如题
...全文
369 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
珺珺 2009-11-17
  • 打赏
  • 举报
回复
晕,你这不已经是自增列了吗,自增列能输入字符串?
lc12d 2009-07-06
  • 打赏
  • 举报
回复
Type.GetType("System.String") 我已经定义过类型了,可是出错的地方说我filepath的类型是int32型,不懂,请教了,谁还没睡啊
蝶恋花雨 2009-07-06
  • 打赏
  • 举报
回复
转换一下ds.Tables["news"].Rows[i]["filepath"].ToString() = ds.Tables["news"].Rows[i]["content"].ToString().Substring(0,11)+"..."; 这样试试
jerryma888888 2009-07-06
  • 打赏
  • 举报
回复

ToString.Substring(0,11)+"...";

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧