大哥们,救救小弟哈!

fox0897 2006-07-28 08:39:46

private void frmSelect_Load(object sender, System.EventArgs e)
{
cn = new SqlConnection (" server = .; uid = sa; pwd = sa; database = test ");
sd = new SqlDataAdapter(" select * from goods ",cn);
ds = new DataSet();
dataGrid1 .DataSource = ds;
try
{
sd.Fill(ds,"goods");
txtName.DataBindings.Add("Text",ds,"goods.供货人姓名");
}
catch(Exception Err)
{
MessageBox.Show("出错啦!"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);

}
}

private void btnSearch_Click(object sender, System.EventArgs e)
{
try
{
if(txtName .Text != String .Empty )
{
string str = "select sum(当前金额) as 合计 from goods where 供货人姓名 = '" + txtName .Text + "'";
com = new SqlCommand(str,cn);
cn.Open();
com.ExecuteNonQuery ();
cn.Close();
}
else
{
MessageBox .Show ("请输入查询信息!");
}
}
catch(Exception Err)
{
MessageBox .Show ("错误代码:"+Err.Message ,"错误信息:",MessageBoxButtons .YesNoCancel );
}
}
此行代码没的任何错误,却无法正常执行,帮忙找错哈!
...全文
63 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
MyLf 2006-07-28
  • 打赏
  • 举报
回复
1.dataGrid1的数据源为dataset,则需要指定dataGrid1.DataMember="goods".

2.你search的功能是干啥用,com.ExecuteNonQuery ();只是在数据库中执行一下sql语句,你又没有返回值。。。。
ziyan0218 2006-07-28
  • 打赏
  • 举报
回复
up

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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