Im trying to get my connection string from one form to another but it keeps passing NULL Im new to working with different classes so it could be a verry simple mistake.
Form 1
public partial class Form1 : Form
{
    private string ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ruben\Documents\dbPlatenCompany.mdf;Integrated Security = True; Connect Timeout = 30";
    public Form1()
    {
        InitializeComponent();
    }
    public string getConnectionString()
    {
        return ConnectionString;
    }
    private void btn_login_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConnectionString);
        SqlDataAdapter sqa = new SqlDataAdapter("Select count(*) From tblLogin where Username ='" + txt_username.Text + "' and Password ='" + txt_password.Text + "'", con);
        DataTable dt = new DataTable();
        sqa.Fill(dt);
        if (dt.Rows[0][0].ToString() == "1") 
        {
            this.Hide();
            Form2 main = new Form2();
            main.Show();
        }
        else
        {
            MessageBox.Show("Username or Password is incorrect");
            txt_username.Clear();
            txt_password.Clear();
        }
    }
}
Form 2
public partial class Form2 : Form
{
    private Form1 form1;
    public Form2()
    {
        InitializeComponent();
    }
    private void btn_search_Click(object sender, EventArgs e)
    {
        if (rb_Artist.Checked == true)
        {
            String ConnectionString = form1.getConnectionString();
            SqlConnection con = new SqlConnection(ConnectionString);
            SqlDataAdapter sqa = new SqlDataAdapter("SELECT * FROM tblArtist where Name like" + txt_search.Text, con);
            DataTable dt = new DataTable();
            sqa.Fill(dt);
            dataGridView1.DataSource = dt;
        }
    }
}
 
     
     
    