回 帖 发 新 帖 刷新版面

主题:无法将方法组“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”。您是要调用方法吗?    
为什么会这样

回复列表 (共2个回复)

沙发

调用方法要用括号把参数括起来,没有参数也不能省略括号

板凳

试试
谢谢你

我来回复

您尚未登录,请登录后再回复。点此登录或注册