code_junkie

Exception of type 'System.OutOfMemoryException' was thrown. Why?

Nov 12th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. public static DataSet GetDataSet(string databaseName,string
  2. storedProcedureName,params object[] parameters)
  3. {
  4. //Creates blank dataset
  5. DataSet ds = null;
  6.  
  7. try
  8. {
  9. //Creates database
  10. Database db = DatabaseFactory.CreateDatabase(databaseName);
  11. //Creates command to execute
  12. DbCommand dbCommand = db.GetStoredProcCommand(storedProcedureName);
  13. dbCommand.CommandTimeout = COMMAND_TIMEOUT;
  14. //Returns the list of SQL parameters associated with that stored proecdure
  15. db.DiscoverParameters(dbCommand);
  16.  
  17. int i = 1;
  18. //Loop through the list of parameters and set the values
  19. foreach (object parameter in parameters)
  20. {
  21. dbCommand.Parameters[i++].Value = parameter;
  22. }
  23. //Retrieve dataset and set to ds
  24. ds = db.ExecuteDataSet(dbCommand);
  25. }
  26. //Check for exceptions
  27. catch (SqlException sqle)
  28. {
  29. throw sqle;
  30. }
  31. catch (Exception e)
  32. {
  33. throw e; // Error is thrown here.
  34. }
  35. //Returns dataset
  36. return ds;
  37. }
  38.  
  39. protected void btnSearchSBIDatabase_Click(object sender, EventArgs e)
  40. {
  41.  
  42. LicenseSearch ls = new LicenseSearch();
  43.  
  44. DataTable dtSearchResults = new DataTable();
  45.  
  46. dtSearchResults = ls.Search();
  47.  
  48. Session["dtSearchResults"] = dtSearchResults;
  49.  
  50. Response.Redirect("~/FCCSearch/SearchResults.aspx");
  51. }
  52. else
  53. lblResults.Visible = true;
  54. }
Add Comment
Please, Sign In to add comment