Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MySQL Procedure - where user readonly has read and execute auth
- CREATE DEFINER=`root`@`localhost` PROCEDURE `TEST`(OUT V_VAR VARCHAR(10))
- BEGIN
- DECLARE V_ID INT;
- SELECT MAX(ID) INTO V_ID FROM storedprocandfunccalllog;
- INSERT INTO storedprocandfunccalllog VALUES(V_ID,"Test",NOW());
- SELECT 'OUCH' INTO V_VAR FROM DUAL;
- SELECT @V_VAR;
- END
- //Default.aspx.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Text;
- using System.Data;
- using MySql.Data;
- using MySql.Data.MySqlClient;
- public partial class _Default : Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- MySqlConnection conn = new MySqlConnection();
- conn.ConnectionString = "Server=localhost; Database=mine; User=READONLY; Password=readonly; Port=3306";
- MySqlCommand cmd = new MySqlCommand();
- Response.Write("<script>alert('Here');</script>");
- conn.Open();
- cmd.Connection = conn;
- cmd.CommandText = "Call Test(@V_VAR);";
- cmd.CommandType = CommandType.Text;
- cmd.Parameters.Clear();
- cmd.Parameters.Add(new MySqlParameter("@V_VAR", "VarChar"));
- cmd.Parameters["@V_VAR"].DbType = System.Data.DbType.String;
- cmd.Parameters["@V_VAR"].Direction = ParameterDirection.Output;
- Response.Write("<script>alert('Here');</script>");
- Response.Write("<script>console.log('Command Test: ');</script>");
- Response.Write("<script>console.log('Command Test: " + cmd.CommandText + "');console.log('Command Parameters: '); console.log('" + cmd.Parameters + "');</script>");
- try
- {
- MySqlDataReader myReader;
- myReader = cmd.ExecuteReader();
- while (myReader.Read())
- { Console.WriteLine(myReader.GetString(0)); }
- Console.WriteLine("Return Value: " + cmd.Parameters["@V_VAR"].Value);
- HelloWorldLabel.Text = cmd.Parameters["@V_VAR"].Value.ToString();
- Response.Write("<script>console.log('Here');</script>");
- }
- catch (MySql.Data.MySqlClient.MySqlException ex)
- {
- Response.Write("<script>alert('Error' );</script>");
- Response.Write("<script>alert("Error: "+"+ ex.Number + "+" has occurred: " + ex.Message + "");</script>");
- Response.Write("<script>console.log("Error: "+" + ex.Number + "+" has occurred: " + ex.Message + "");</script>");
- }
- conn.Close();
- Response.Write("<script>alert('Done');</script>");
- }
- }
- Data is Null. This method or property cannot be called on Null values.
- 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.
- Exception Details: System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
- Source Error:
- Line 45: {
- Line 46: MySqlDataReader myReader;
Add Comment
Please, Sign In to add comment