私はコードのビットがあります「subbut_Click」マッチデリゲートのための過負荷「System.EventHandler」
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Globalization;
namespace DEMO
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void brwbut_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void subbut_Click(string fileName, string tableName)
{
string connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Mode=ReadWrite;Extended Properties=\"Excel 8.0;HDR=NO\"";
string fieldstring = "(ID int, Field1 char(255),Field2 char(255))";
using (OleDbConnection conn = new OleDbConnection())
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = conn;
cmd.CommandText = string.Format(CultureInfo.InvariantCulture, @"CREATE TABLE [{0}] {1}", tableName, fieldstring);
cmd.ExecuteNonQuery();
}
conn.Close();
}
}
public void InsertRow(String fileName, String tableName, string data)
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Mode=ReadWrite;Extended Properties=\"Excel 8.0;HDR=YES\"";
string headers = "ID,Field1,Field2";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = conn;
cmd.CommandText = string.Format(CultureInfo.InvariantCulture, @"INSERT INTO [{0}$] ({1}) values({2})", tableName, headers, data);
//txtQuery.Text = cmd.CommandText;
cmd.ExecuteNonQuery();
}
for (int i = 0; i < 10; i++)
{
InsertRow("C:\\path\\to\\file\\Test File.xls", "ListingDetails",
"'" + i.ToString() + "','test" + (i + 2).ToString() + "','test" + (i + 5).ToString() + "'");
}
conn.Close();
}
}
}
}
をしかし、私は「subbut_Click」の
ませ過負荷を迷惑なエラーを取得していない保ちます代理人 'System.EventHandler'と一致します
私はアプローチする方法がわかりません。私はオンラインで検索していましたし、しばらくの間撮影していて、何の答えも見つけられていません。どんな提案も大歓迎です。
これらのパラメータはどのようなものだと思いますか? – SLaks