大哥们,救救小弟哈!
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 );
}
}
此行代码没的任何错误,却无法正常执行,帮忙找错哈!