I need help to call a function while passing strings from one form to another when clicking a button.
Form1 (Form1) has the MySQL connection and "Select" statements needed to verify the login.
Form2 (LoginWindow) has the Login user and password TextBoxes and Login button.
The error I get is: "Cannot implicitly convert type 'void' to 'Application.Main.App.Form1.MyFunctionExposed'"
Here is what I have:
Form1.cs:
namespace Application.Main
{
public partial class Form1 : Form
{
public string strUser;
public string strPass;
public delegate void MyFunctionExposed();
public static MyFunctionExposed functionMySQLCheckLogin;
public Form1()
{
InitializeComponent();
functionMySQLCheckLogin = CheckLogin(strUser, strPass);
}
//Check Login
public void CheckLogin(string strUser, string strPass)
{
try
{
//Open connection
string query = "SELECT * FROM users WHERE user_name = '" + strUser + "' AND user_password = '" + strPass + "' ";
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command and the rest of the MySQL query code
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
Form2.cs
namespace Application
{
public partial class LoginWindow : Form
{
public LoginWindow()
{
InitializeComponent();
}
private void LoginWindow_Load(object sender, EventArgs e)
{
}
private void btnLoginGo_Click(object sender, EventArgs e)
{
Application.Main.Form1.functionMySQLCheckLogin(inputBoxLoginUser.Text, inputBoxLoginPassword.Text);
}
}
Any ideas how to fix this or do it differently using these two Forms? Thanks.