Click here to Skip to main content
15,881,380 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Trying to create modal dialog using jQuery Pin
Richard Deeming9-Aug-17 10:10
mveRichard Deeming9-Aug-17 10:10 
GeneralRe: Trying to create modal dialog using jQuery Pin
indian1439-Aug-17 11:44
indian1439-Aug-17 11:44 
GeneralRe: Trying to create modal dialog using jQuery Pin
F-ES Sitecore9-Aug-17 23:11
professionalF-ES Sitecore9-Aug-17 23:11 
GeneralRe: Trying to create modal dialog using jQuery Pin
indian14310-Aug-17 13:03
indian14310-Aug-17 13:03 
GeneralRe: Trying to create modal dialog using jQuery Pin
F-ES Sitecore10-Aug-17 22:09
professionalF-ES Sitecore10-Aug-17 22:09 
GeneralRe: Trying to create modal dialog using jQuery Pin
indian14311-Aug-17 13:13
indian14311-Aug-17 13:13 
GeneralRe: Trying to create modal dialog using jQuery Pin
F-ES Sitecore13-Aug-17 22:18
professionalF-ES Sitecore13-Aug-17 22:18 
QuestionProcedure or function 'sp_getchech' expects parameter '@ID', which was not supplied Pin
samflex9-Aug-17 5:24
samflex9-Aug-17 5:24 
This is supposed to be simple.

I have a very simple stored proc which selects records based on ID provided by user.

ALTER PROCEDURE [dbo].[sp_getcheck]
@ID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

SET NOCOUNT ON;
If NOT EXISTS(select * from mytable where ID=@ID)
  BEGIN
	RAISERROR (
    'ID number entered %d is invalid',
    11,
    1,
    @ID);
  END
END


What we would like to do is have user enter an ID and check to see if it exists on our database.

If yes, user is redirected to a page of his/her choice.

If no, we would like to keep user on same screen with a message that ID number entered Q1254 is invalid.

That error is raised on the stored procedure and we would like C# code to display that message on the screen for the user.

Here is that code:

protected void chk_Click(object sender, EventArgs e)
{

    if (!string.IsNullOrEmpty(checknumber.Text))
    {
        SqlConnection Conn = default(SqlConnection);

        //Read in connection String
        Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Constr"].ConnectionString);
        Conn.Open();

        SqlCommand cmd = new SqlCommand("sp_getcheck", Conn);
        //Retrieve the value of the output parameter

        //Add the output parameter to the command object
        cmd.Parameters.AddWithValue("@ID", checknumber.Text);
        SqlParameter outPutParameter = new SqlParameter();
        SqlDataReader dr = cmd.ExecuteReader();

        //Retrieve the value of the output parameter

        if (dr.Read())
        {
            try
            {
                //we add a hidden field called IsValid to the markup and set the IsValid value in the event handler here.
                imgstatus.ImageUrl = "images/Icon_Available.gif";
                lblStatus.ForeColor = Color.Green;

                //redirect based on value of hidden form field called evalue
                var evalue = hequipID.Value;
                if (evalue == "1")
                {
                    Response.Redirect("Air.aspx?pageId=1");
                }
                if (evalue == "2")
                {
                    Response.Redirect("Land.aspx?pageId=2");
                }

                //ID exists, get form fields and store db values in them:
                //txtfname.Text = (dr["FullName"].ToString());

            }
            catch (SqlException ex)
            {
                //Something is wrong with this taxpayer's account.
                imgstatus.ImageUrl = "images/NotAvailable.jpg";
                lblStatus.ForeColor = Color.Red;
                lblStatus.Text = ex.Message;
                chk.BackColor = Color.Silver;
                System.Threading.Thread.Sleep(2000);
            }
        }
    }
  }


en I tried to run the code, I get the following error message:

Procedure or function 'sp_getchech' expects parameter '@ID', which was not supplied

Surely I am doing something wrong.

Any ideas how to resolve this?

Thanks in advance

modified 9-Aug-17 11:47am.

AnswerRe: Procedure or function 'sp_getchech' expects parameter '@ID', which was not supplied Pin
Richard Deeming9-Aug-17 8:14
mveRichard Deeming9-Aug-17 8:14 
GeneralRe: Procedure or function 'sp_getchech' expects parameter '@ID', which was not supplied (SOLVED) Pin
samflex9-Aug-17 14:54
samflex9-Aug-17 14:54 
QuestionWhat is better solutions for complex application and databases Pin
Lakhpat-Singh8-Aug-17 7:22
Lakhpat-Singh8-Aug-17 7:22 
AnswerRe: What is better solutions for complex application and databases Pin
F-ES Sitecore9-Aug-17 0:00
professionalF-ES Sitecore9-Aug-17 0:00 
QuestionGetting Route Values in Controller Pin
Farhad Eft7-Aug-17 7:20
Farhad Eft7-Aug-17 7:20 
AnswerRe: Getting Route Values in Controller Pin
Richard Deeming7-Aug-17 10:21
mveRichard Deeming7-Aug-17 10:21 
GeneralRe: Getting Route Values in Controller Pin
Farhad Eft7-Aug-17 13:19
Farhad Eft7-Aug-17 13:19 
Questiontrying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian14331-Jul-17 15:26
indian14331-Jul-17 15:26 
AnswerRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
Richard Deeming1-Aug-17 0:50
mveRichard Deeming1-Aug-17 0:50 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian1431-Aug-17 7:01
indian1431-Aug-17 7:01 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
Richard Deeming1-Aug-17 7:24
mveRichard Deeming1-Aug-17 7:24 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian1431-Aug-17 13:23
indian1431-Aug-17 13:23 
QuestionI would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
Lad Kunal30-Jul-17 20:14
Lad Kunal30-Jul-17 20:14 
AnswerRe: I would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
Richard MacCutchan30-Jul-17 20:42
mveRichard MacCutchan30-Jul-17 20:42 
AnswerRe: I would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
indian1432-Aug-17 6:57
indian1432-Aug-17 6:57 
QuestionError message: The operation cannot be completed because the DbContext has been disposed Pin
indian14327-Jul-17 11:39
indian14327-Jul-17 11:39 
AnswerRe: Error message: The operation cannot be completed because the DbContext has been disposed Pin
Richard Deeming28-Jul-17 1:31
mveRichard Deeming28-Jul-17 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.