Guest User

Untitled

a guest
Jan 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. da.Update(ds1, "Table1");
  2.  
  3. int MaxRows = 0;
  4. int inc = 0;
  5.  
  6. private void Form2_Load(object sender, EventArgs e)
  7. {
  8. con = new System.Data.OleDb.OleDbConnection();
  9. ds1 = new DataSet();
  10.  
  11. con.ConnectionString = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Documents and Settings/user/My Documents/anchu.accdb";
  12. string sql = "SELECT * From Table1";
  13. da = new System.Data.OleDb.OleDbDataAdapter(sql, con);
  14.  
  15. con.Open();
  16.  
  17. da.Fill(ds1, "Table1");
  18. //NavigateRecords();
  19.  
  20. con.Close();
  21. //con.Dispose();
  22. }
  23. /*private void NavigateRecords()
  24. {
  25. DataRow drow = ds1.Tables["Table1"].Rows[0];
  26.  
  27. textBox1.Text = drow.ItemArray.GetValue(0).ToString();
  28. textBox2.Text = drow.ItemArray.GetValue(1).ToString();
  29. textBox3.Text = drow.ItemArray.GetValue(2).ToString();
  30. textBox4.Text = drow.ItemArray.GetValue(3).ToString();
  31.  
  32.  
  33.  
  34.  
  35.  
  36. }*/
  37.  
  38.  
  39. private void groupBox1_Enter(object sender, EventArgs e)
  40. {
  41.  
  42. }
  43.  
  44. private void button2_Click(object sender, EventArgs e)
  45. {
  46. textBox1.Clear();
  47. textBox2.Clear();
  48. textBox3.Clear();
  49. textBox4.Clear();
  50. }
  51.  
  52. private void button1_Click(object sender, EventArgs e)
  53. {
  54. System.Data.OleDb.OleDbCommandBuilder cb;
  55. cb = new System.Data.OleDb.OleDbCommandBuilder(da);
  56.  
  57. DataRow drow = ds1.Tables["Table1"].NewRow();
  58. drow[0] = textBox1.Text;
  59. drow[1] = textBox2.Text;
  60. drow[2] = textBox3.Text;
  61. drow[3] = textBox4.Text;
  62.  
  63. ds1.Tables["Table1"].Rows.Add(drow);
  64.  
  65. MaxRows = MaxRows + 1;
  66. inc = MaxRows - 1;
  67.  
  68. da.Update(ds1, "Table1");
  69.  
  70. MessageBox.Show("Entry Added");
  71.  
  72.  
  73. }
  74. }
  75. }
Add Comment
Please, Sign In to add comment