Guest User

Untitled

a guest
Feb 11th, 2019
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. //MySQL Procedure - where user readonly has read and execute auth
  2. CREATE DEFINER=`root`@`localhost` PROCEDURE `TEST`(OUT V_VAR VARCHAR(10))
  3. BEGIN
  4. DECLARE V_ID INT;
  5. SELECT MAX(ID) INTO V_ID FROM storedprocandfunccalllog;
  6. INSERT INTO storedprocandfunccalllog VALUES(V_ID,"Test",NOW());
  7.  
  8. SELECT 'OUCH' INTO V_VAR FROM DUAL;
  9. SELECT @V_VAR;
  10. END
  11.  
  12. //Default.aspx.cs
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Web;
  17. using System.Web.UI;
  18. using System.Web.UI.WebControls;
  19. using System.Text;
  20.  
  21. using System.Data;
  22. using MySql.Data;
  23. using MySql.Data.MySqlClient;
  24.  
  25. public partial class _Default : Page
  26. {
  27. protected void Page_Load(object sender, EventArgs e)
  28. {
  29. MySqlConnection conn = new MySqlConnection();
  30. conn.ConnectionString = "Server=localhost; Database=mine; User=READONLY; Password=readonly; Port=3306";
  31. MySqlCommand cmd = new MySqlCommand();
  32. Response.Write("<script>alert('Here');</script>");
  33.  
  34. conn.Open();
  35. cmd.Connection = conn;
  36.  
  37. cmd.CommandText = "Call Test(@V_VAR);";
  38. cmd.CommandType = CommandType.Text;
  39. cmd.Parameters.Clear();
  40. cmd.Parameters.Add(new MySqlParameter("@V_VAR", "VarChar"));
  41. cmd.Parameters["@V_VAR"].DbType = System.Data.DbType.String;
  42. cmd.Parameters["@V_VAR"].Direction = ParameterDirection.Output;
  43. Response.Write("<script>alert('Here');</script>");
  44. Response.Write("<script>console.log('Command Test: ');</script>");
  45. Response.Write("<script>console.log('Command Test: " + cmd.CommandText + "');console.log('Command Parameters: '); console.log('" + cmd.Parameters + "');</script>");
  46.  
  47. try
  48. {
  49. MySqlDataReader myReader;
  50. myReader = cmd.ExecuteReader();
  51. while (myReader.Read())
  52. { Console.WriteLine(myReader.GetString(0)); }
  53. Console.WriteLine("Return Value: " + cmd.Parameters["@V_VAR"].Value);
  54. HelloWorldLabel.Text = cmd.Parameters["@V_VAR"].Value.ToString();
  55. Response.Write("<script>console.log('Here');</script>");
  56. }
  57. catch (MySql.Data.MySqlClient.MySqlException ex)
  58. {
  59. Response.Write("<script>alert('Error' );</script>");
  60. Response.Write("<script>alert("Error: "+"+ ex.Number + "+" has occurred: " + ex.Message + "");</script>");
  61. Response.Write("<script>console.log("Error: "+" + ex.Number + "+" has occurred: " + ex.Message + "");</script>");
  62. }
  63. conn.Close();
  64. Response.Write("<script>alert('Done');</script>");
  65. }
  66. }
  67.  
  68. Data is Null. This method or property cannot be called on Null values.
  69. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  70.  
  71. Exception Details: System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
  72.  
  73. Source Error:
  74.  
  75.  
  76.  
  77. Line 45: {
  78. Line 46: MySqlDataReader myReader;
Add Comment
Please, Sign In to add comment