实在莫名其妙:(大家帮忙看看吧!!谢谢

musicfree_uibe 2003-12-22 09:14:33



return (new recruitStudents()).InsertRecruitStudent(ds);




public bool InsertRecruitStudent(recruitStudentData student)
{
DataRow row = student.Tables["TableName"].Rows[0];
SqlConnection conn = new SqlConnection("workstation id=\"FIVEBODY-XUCHI\";packet size=4096;user id=sa;data source=\"202.204.165.112\";persist security info=True;initial catalog=teST;password=***");
conn.Open();
String strSql = "insert into .....";
Console.WriteLine(strSql);
insertCommand = new SqlCommand(strSql,conn);
insertCommand.ExecuteNonQuery();
conn.Close();
return true;
}


结果调试的时候row和strSwl都显示为null -_-!!!
怎么回事???
...全文
40 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xupc 2003-12-22
  • 打赏
  • 举报
回复
显示为null,没报异常?
musicfree_uibe 2003-12-22
  • 打赏
  • 举报
回复
谢谢:)
不过to: bankliu
我的student里面是填充了数据集的!
SQL语句用的是insert!!!
bankliu 2003-12-22
  • 打赏
  • 举报
回复
DataRow row = student.Tables["TableName"].Rows[0];
你要明白的意思:
首先,要建立与Tables["TableName"]一样格式的一个空行!
然后才被被赋值
student.Tables["TableName"].Rows[0];
应该是:student.Tables["TableName"].NewRow()
hiyo 2003-12-22
  • 打赏
  • 举报
回复
关注,帮你顶!

110,538

社区成员

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

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

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