[英]how to create c# exe?
如何为此C#程序创建exe文件。 我确实尝试创建一个exe文件但是出现了一些错误,错误是,
'WindowsFormsApplication11.save' does not contain a definition for 'save_Load' and no extension method 'save_Load' accepting a first argument of type 'WindowsFormsApplication11.save' could be found (are you missing a using directive or an assembly reference?)
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.SqlClient;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication11
{
public partial class save : Form
{
public save()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string myConnection = "datasource=localhost;port=3306;username=root;Password=root";
string query = "insert into store_data.item_details (item_id,item_name,item_qty,item_price) values('" + this.id_txt.Text + "','" + this.name_txt.Text + "','" + this.qty_txt.Text + "','" + this.price_txt.Text + "');";
MySqlConnection connection = new MySqlConnection(myConnection);
MySqlCommand cmdsave = new MySqlCommand(query, connection);
MySqlDataReader dataReader;
try
{
connection.Open();
dataReader = cmdsave.ExecuteReader();
MessageBox.Show("your Data has been saved ");
while (dataReader.Read())
{
}
connection.Close();
}
catch (Exception excep)
{
MessageBox.Show(excep.Message);
}
}
}
}
您可能曾经尝试编写在表单加载上执行的代码,然后删除了load方法。 该错误来自于仍然存在对该方法不再存在的引用这一事实。
解决方案只是双击Visual Studio中的错误并删除导致问题的行,这些行将引用现在不存在的方法。
你似乎错过了一个事件处理程序,它可能是在设计器中指定的。 删除对它的引用,或者定义它,可能是这样的:
save_Load(object sender, EventArgs e) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.