Guest User

Untitled

a guest
Dec 10th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. //first form
  2. private void button1_Click(object sender, EventArgs e)
  3. {
  4. Form1 f2 = new Form1();
  5. f2.Text = comboBox2.Text;
  6.  
  7. Form1 f3 = new Form1();
  8. f3.Text = comboBox1.Text;
  9.  
  10. Form1 f4 = new Form1();
  11. f4.Text = textBox1.Text;
  12.  
  13. //second form
  14. public partial class Form1 : Form
  15. {
  16.  
  17. private string text1;
  18. public string Text1
  19. {
  20. get { return text1; }
  21. set { Text1 = value; }
  22. }
  23.  
  24. private string text2;
  25. public string Text2
  26. {
  27. get { return text2; }
  28. set { text2 = value; }
  29. }
  30.  
  31. private string text3;
  32. public string Text3
  33. {
  34. get { return text3; }
  35. set { text3 = value; }
  36. }
  37.  
  38. public Form1(Form1 frm1)
  39. {
  40. InitializeComponent();
  41. }
  42.  
  43. private void Form1_Load(object sender, EventArgs e)
  44. {
  45.  
  46. string db = Text1;
  47. string user = Text2;
  48. string pass = Text3;
  49.  
  50. String strConnection = @"Data Source=SERVER;Initial Catalog ="+db+"; User ID ="+user+"; Password ="+pass+";";
  51. SqlConnection con = new SqlConnection(strConnection);
  52.  
  53. try
  54. {
  55. con.Open();
  56. SqlCommand sqlCmd = new SqlCommand();
  57. sqlCmd.Connection = con;
  58. sqlCmd.CommandType = CommandType.Text;
  59. sqlCmd.CommandText = "Select table_name from information_schema.tables";
  60. SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
  61. DataTable dtRecord = new DataTable();
  62. sqlDataAdap.Fill(dtRecord);
  63. dtRecord.DefaultView.Sort = "table_name ASC";
  64. ComboBox1.DataSource = dtRecord;
  65. ComboBox1.DisplayMember = "TABLE_NAME";
  66. con.Close();
  67. }
  68. catch (Exception ex)
  69. {
  70. MessageBox.Show(ex.Message);
  71.  
  72. }
Add Comment
Please, Sign In to add comment