Guest User

Untitled

a guest
Jan 19th, 2019
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string sqlInsert = "insert into assessment (id) values (@id)";
  2.  
  3. using (OleDbConnection conn = new OleDbConnection(dsn))
  4. {
  5.  
  6. OleDbCommand cmd = new OleDbCommand(sqlInsert, conn);
  7.  
  8. cmd.Parameters.Add("@id", OleDbType.VarChar, 50).Value = iDTextBox.Text.Trim().Length != null ? storedID.Trim() : "";
  9.  
  10. conn.Open();
  11. cmd.ExecuteNonQuery();
  12. conn.Close();
  13. }
  14.  
  15. <add name="conn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|CADSCUPP.mdb" providerName="System.Data.OleDb"/>
  16.  
  17. private string dsn = System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
  18.  
  19. string sqlInsert = "insert into assessment (id) values (?)";
  20.  
  21. using (OleDbConnection conn = new OleDbConnection(dsn))
  22. {
  23.  
  24. OleDbCommand cmd = new OleDbCommand(sqlInsert, conn);
  25.  
  26. cmd.Parameters.Add("?", OleDbType.VarChar, 50).Value = iDTextBox.Text.Trim().Length == 0 ? storedID.Trim() : "";
  27.  
  28. conn.Open();
  29. cmd.ExecuteNonQuery();
  30. conn.Close();
  31. }
  32.  
  33. connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;"
RAW Paste Data