Hii buddy
after saw your q.s 1st i done it practically and after successfully debug now here for you
On Form1..................
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;
namespace form1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class shubh
{
public string shubham;
}
private void btnlogin_Click(object sender, EventArgs e)
{
try
{
con = new SqlConnection(s);
con.Open();
cmd = new SqlCommand("select username,password from login",con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr["username"].ToString() == username && dr["password"].ToString() == password)
{
shubh s = new shubh();
s.shubham = txtusername.Text;
Form2 hmpage = new Form2(s);
hmpage.Show();
this.Hide();
}
else
{
MessageBox.Show("The username or password you entered is incorrect!", "Logon Message!");
}
}
con.Close();
dr.Close();
}
catch (Exception ex)
{
}
}
}
}
Now on form2................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tarriff_design_page
{
public partial class Home : Form
{
form1.Form1.shubh s;
public string sa;
public Home(form1.Form1.shubh s1)
{
InitializeComponent();
s = s1;
}
private void Form2_Load(object sender, EventArgs e)
{
sa =s.shubham ;
label1.Text = s.shubham;
}
}
}
this will definitely run successfully but the main issue with your partial class of form one and form to here just i used form1 for 1st page and form2 for 2nd page so carefully change this nominations as your both forms that can help you to achieve your necessity ........ thanks
Happy to help