Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //first form
- private void button1_Click(object sender, EventArgs e)
- {
- Form1 f2 = new Form1();
- f2.Text = comboBox2.Text;
- Form1 f3 = new Form1();
- f3.Text = comboBox1.Text;
- Form1 f4 = new Form1();
- f4.Text = textBox1.Text;
- //second form
- public partial class Form1 : Form
- {
- private string text1;
- public string Text1
- {
- get { return text1; }
- set { Text1 = value; }
- }
- private string text2;
- public string Text2
- {
- get { return text2; }
- set { text2 = value; }
- }
- private string text3;
- public string Text3
- {
- get { return text3; }
- set { text3 = value; }
- }
- public Form1(Form1 frm1)
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- string db = Text1;
- string user = Text2;
- string pass = Text3;
- String strConnection = @"Data Source=SERVER;Initial Catalog ="+db+"; User ID ="+user+"; Password ="+pass+";";
- SqlConnection con = new SqlConnection(strConnection);
- try
- {
- con.Open();
- SqlCommand sqlCmd = new SqlCommand();
- sqlCmd.Connection = con;
- sqlCmd.CommandType = CommandType.Text;
- sqlCmd.CommandText = "Select table_name from information_schema.tables";
- SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
- DataTable dtRecord = new DataTable();
- sqlDataAdap.Fill(dtRecord);
- dtRecord.DefaultView.Sort = "table_name ASC";
- ComboBox1.DataSource = dtRecord;
- ComboBox1.DisplayMember = "TABLE_NAME";
- con.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
Add Comment
Please, Sign In to add comment