Hi
I have below code but it is not going in Load function
using Sap.Data.Hana;
namespace Atulaya
{
public partial class Form1 : Form
{
HanaConnection conn;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new HanaConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Hana"].ConnectionString);
conn.Open();
Console.WriteLine("Connected");
}
}
}
Thanks
Jayraj ChhayaPosted Dec 11, 2024, 10:49 AM
Hi Ramco,
The issue you're encountering may stem from the fact that the
Form1_Loadevent is not properly wired up to the form's Load event. To resolve this, ensure that theForm1_Loadmethod is correctly associated with the Load event of the form. You can do this in the designer or programmatically in the constructorAdditionally, ensure that your connection string in the configuration file is correctly set up and that the
Sap.Data.Hanalibrary is properly referenced in your project. If the connection fails, the message "Connected" will not be displayed.Lastly, consider using
MessageBox.Show("Connected");instead ofConsole.WriteLineto display the message in a Windows Forms application, asConsole.WriteLinemay not show output in the UI context.Amit MohantyPosted Dec 11, 2024, 6:09 AM
Make sure that the Form1_Load event is assigned to the form's Load event. This can be either in the designer or manually in your code. Check that, in your designer file (Form1.Designer.cs), the Load event is hooked up like this: