日期:2014-05-17 浏览次数:21157 次
public void DataBaseInSertFromOperateDataSet(string DataTableName, string ValueOfFieldString)
{
if (this.OleDbCommandString != null && this.ConnectionString != null)
{
this._ConnectionString = ConnectionString;
this._OleDbCommandString = OleDbCommandString;
MyConnection = new OleDbConnection(_ConnectionString);
MyDataAdapter = new OleDbDataAdapter(_OleDbCommandString, MyConnection);
MyDataSet = new DataSet();
MyDataAdapter.Fill(MyDataSet, DataTableName);
MyDataTable = MyDataSet.Tables[DataTableName];
string[] ColumnName = new string[MyDataTable.Columns.Count];
int i = 0;
foreach (DataColumn Dc in MyDataTable.Columns)
{
ColumnName[i] = Dc.ColumnName;
i++;
}
string[] ValueOfField = ValueOfFieldString.Split(new char[] { ',' });
if (ValueOfField.Length != ColumnName.Length)
{
MessageBox.Show("您输入的字段个数与数据库不匹配");
}
else
{