主题:无法将方法组“NewRow”转换为非委托类型“System.Data.DataRow”
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
public partial class index : Form
{
private DataSet mydataset;
private DataTable mydatatable;
private DataRow mydatarow;
private OleDbCommand mydatacommand;
private OleDbDataAdapter mydataadapter;
private OleDbConnection myassecccon;
private OleDbCommandBuilder custcb;
public index()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“teldb1DataSet.表1”中。您可以根据需要移动或移除它。
// this.表1TableAdapter.Fill(this.teldb1DataSet.tel);
// TODO: 这行代码将数据加载到表“teldb1DataSet.表1”中。您可以根据需要移动或移除它。
//this.表1TableAdapter.Fill(this.teldb1DataSet.tel);
string myassecccon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Application.StartupPath + "\\db1.mdb";
OleDbConnection aConnection = new OleDbConnection(myassecccon);
string strasseccselect = "select * form tel";
mydataset = new DataSet();
mydataset.Tables.Add("tel");
mydataadapter.SelectCommand.CommandText = strasseccselect;
mydataadapter.Fill(mydataset, "tel");
custcb = new OleDbCommandBuilder(mydataadapter);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button_Click(object sender, EventArgs e)
{
mydatarow = mydatatable.NewRow;
mydatarow ["tel"] = telbox.Text.ToString();
}
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
}
}
}[color=000080][/color]
错误 1 无法将方法组“NewRow”转换为非委托类型“System.Data.DataRow”。您是要调用方法吗?
为什么会这样
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
public partial class index : Form
{
private DataSet mydataset;
private DataTable mydatatable;
private DataRow mydatarow;
private OleDbCommand mydatacommand;
private OleDbDataAdapter mydataadapter;
private OleDbConnection myassecccon;
private OleDbCommandBuilder custcb;
public index()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“teldb1DataSet.表1”中。您可以根据需要移动或移除它。
// this.表1TableAdapter.Fill(this.teldb1DataSet.tel);
// TODO: 这行代码将数据加载到表“teldb1DataSet.表1”中。您可以根据需要移动或移除它。
//this.表1TableAdapter.Fill(this.teldb1DataSet.tel);
string myassecccon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Application.StartupPath + "\\db1.mdb";
OleDbConnection aConnection = new OleDbConnection(myassecccon);
string strasseccselect = "select * form tel";
mydataset = new DataSet();
mydataset.Tables.Add("tel");
mydataadapter.SelectCommand.CommandText = strasseccselect;
mydataadapter.Fill(mydataset, "tel");
custcb = new OleDbCommandBuilder(mydataadapter);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button_Click(object sender, EventArgs e)
{
mydatarow = mydatatable.NewRow;
mydatarow ["tel"] = telbox.Text.ToString();
}
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
}
}
}[color=000080][/color]
错误 1 无法将方法组“NewRow”转换为非委托类型“System.Data.DataRow”。您是要调用方法吗?
为什么会这样