问题描述
- 错误 1 “UpdateDataBase”方法没有任何重载采用“1”个参数
- using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace 进销存管理系统
{
public partial class PopedomManage : Form
{
private DataSet ds = new DataSet();
private LinkDataBase link = new LinkDataBase();
private string sendTableName = ""用户清单"";
private string sendStrSQL = ""SELECT * from 用户清单 where 姓名<>'sys'"";
private DataTable popedomDataTable = new DataTable();
private bool blInitial = true;public PopedomManage() { InitializeComponent(); } private void PopedomManage_Load(object sender System.EventArgs e)
{
this.ds = this.link.SelectDataBase(sendStrSQL sendTableName);this.dgrd_Popedom.DataSource = ds.Tables[0]; this.DataGridStateControl(); this.dgrd_Popedom.Select(); string selectedUserID= this .ds.Tables [0].Rows [0][0].ToString (); string tempStrSQL= ""select 权限名称 from 权限名单 "" + "" where 用户编号 = '"" + selectedUserID + ""'""; popedomDataTable=link.SelectDataBase(tempStrSQL); for (int i=0;i<popedomDataTable.Rows.Count;i++){for (int j=0;j<this.chkLst_Priority.Items.Count;j++){if (this.chkLst_Priority.Items[j].ToString().Trim()==popedomDataTable. Rows[i][0].ToString().Trim()){this.chkLst_Priority.SetItemChecked(jtrue); } }}
}
private void DataGridStateControl() { DataGridTableStyle ts = new DataGridTableStyle(); ts.AlternatingBackColor = Color.LightGray; ts.MappingName = this.ds.Tables[0].TableName; ts.AllowSorting = false; int numCols = this.ds.Tables[0].Columns.Count; this.dgrd_Popedom.TableStyles.Add(ts); } private void chkLst_Priority_ItemCheck(object sender System.Windows.Forms.ItemCheckEventArgs e)
{
if (blInitial == false)
{
if (e.CurrentValue.ToString()==""Unchecked"")
{
try
{string strUserName = this.dgrd_Popedom[this.dgrd_Popedom.CurrentCell.
RowNumber0].ToString().Trim();
string strPopedom = this.chkLst_Priority.SelectedItem.ToString();
string temSendStrSQL = ""insert 权限清单(用户编号,权限名称)values ('"" + strUserName+""''"" + strPopedom+""')"";this.link.UpdateDataBase(temSendStrSQL);
}
catch
{
MessageBox.Show(""数据库中的权限修改出错,请重试!""信息"");}
}
else if (e.CurrentValue.ToString()==""Chencked"") { try { string strUserName = this.dgrd_Popedom[this.dgrd_Popedom.CurrentCell. RowNumber0].ToString().Trim(); string strPopedom =this.chkLst_Priority.SelectedItem.ToString(); string tempSendStrSQL= "" delete from 权限清单 where (用户编号 = '"" + strUserName + ""'"" + ""and 权限清单 = '"" + strPopedom + ""')""; this.link.UpdateDataBase ( tempSendStrSQL ); } catch { MessageBox.Show(""数据库中的权限修改出错!""信息""); } } }} private void dgrd_Popedom_MouseUp(object sender System.Windows.Forms.MouseEventArgs e)
{
if (this.dgrd_Popedom.CurrentCell.RowNumber >= this.ds.Tables[0].Rows.Count)
//防止出现所选的用户不再数据表中的情况
{
return;
}
this.chkLst_Priority.Enabled=true;
blInitial=true; //控制当""权限管理""窗体刚生成时和单击其他用户时使//CheckedListBox控件中数据发生改变时不响应ItemCheck事件//以下代码实现的是当DataGrid中所选用户改变时,根据所选用户重新设置ListBox的//功能for(int i=0;i< this.chkLst_Priority.Items.Count;i++) //将ListBox中所用权限设为未选中{ this.chkLst_Priority.SetItemChecked(ifalse);}int intRowNumber =this.dgrd_Popedom.CurrentCell.RowNumber;string selectedUserID =this.ds.Tables[0].Rows[intRowNumber][0].ToString();string tempStrSQL= "" select 权限名称 from 权限清单 "" + "" where 用户编号 = '"" +
selectedUserID + ""'"";
popedomDataTable=link.SelectDataBase(tempStrSQL); //查询所选用户权限
for(int i=0;i<popedomDataTable.Rows.Count;i++) //重新设置ListBox
{
for(int j=0;j<this.chkLst_Priority.Items.Count;j++)
{
if(this.chkLst_Priority.Items[j].ToString().Trim()==popedomDataTable.
Rows[i][0].ToString().Trim())
{
this.chkLst_Priority.SetItemChecked(jtrue);
}
}
}blInitial=false;
}
}
}
解决方案
你可以在UpdateDataBase上面点右键,然后点转到定义。把UpdateDataBase的定义贴出来。
解决方案二:
UpdateDataBase这个方法在哪里定义的。你调用的参数和它需要的不匹配。
解决方案三:
this.link.UpdateDataBase(this.ds temSendStrSQL);
这样看看
或者
this.link.UpdateDataBase(this.ds 你的表名);
解决方案四:
具体怎么写最好贴出
UpdateDataBase
这个方法的实现。
感觉你是在拿一个人家的程序修改,你要搞清楚原来代码的含义再修改。
解决方案五:
UpdateDataBase方法传递的参数个数不对。
解决方案六:
UpdateDataBase 函数调用参数不对,查看一下定义
解决方案七:
public DataSet UpdateDataBase(DataSet changedDataSet string tableName)
怎样改啊?
解决方案八:
UpdateDataBase 你要传两个参数