in Education by
I'm attempting to call my sql stored procedure which takes RaceDate as an input and returns Location as an OUTPUT. I'm not sure how to call my code in ASP.NET, this is what I have thus far. DateTime RaceDate = Calendar1.SelectedDate; // string RaceDate = TxtBoxCalendar.Text; TxtBoxCalendar.ReadOnly = true; SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ToString(); con.Open(); SqlCommand Command = new SqlCommand(); Command.CommandType = System.Data.CommandType.StoredProcedure; Command.CommandText = "CheckRaceCalendarDates"; Command.Parameters.Add("@RaceDate", SqlDbType.DateTime, RaceDate); Command.Parameters.Add("@Location", SqlDbType.String).Direction = ParameterDirection.Output; Command.Parameters.Add("@Location",SqlDbType.String).Direction = ParameterDirection.Output; Command.ExecuteNonQuery(); con.Close(); I think i may also run into a problem with datatypes. RaceDate is a date the user clicks through a calendar and has to be converted to a string however the SQL parameter RaceDate is of type date. CREATE PROCEDURE [dbo].[CheckRaceCalendarDates] @RaceDates DATE, @Location NVARCHAR(50) OUTPUT AS IF EXISTS ( SELECT RaceCalendar.RaceDates, Locations.LocationName FROM Locations INNER JOIN RaceCalendar ON locations.LocationId = RaceCalendar.LocationId WHERE RaceCalendar.RaceDates = @RaceDates ) BEGIN SELECT @Location = Locations.LocationName FROM Locations INNER JOIN RaceCalendar ON locations.LocationId = RaceCalendar.LocationId WHERE RaceCalendar.RaceDates = @RaceDates END JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Your problem about using parameter name ; you have used @RaceDates on stored procedure but you try to use @RaceDate on code.. They should be same. Also, you need to add second parameter to your code like this ; Command.Parameters.Add("@Location",SqlDbType.String).Direction = ParameterDirection.Output; And after cmd.ExeCuteNonQuery(); string location = Command.Parameters["@Location"].Value.ToString();

Related questions

0 votes
    I'm attempting to call my sql stored procedure which takes RaceDate as an input and returns Location as an ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have batch of user accounts and every user account's password is not crypted.I want to insert to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Basically I recently added a search-box and button to my asp.net site. Issue I'm having now is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Which of the following is used to call stored procedure? (a) Statement (b) PreparedStatement (c) CallableStatment (d ... & JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which of the following is used to call stored procedure? (a) Statement (b) PreparedStatement (c) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Say I have an ASMX web service, MyService. The service has a method, MyMethod. I could execute MyMethod ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 31, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I mock the database calls to make my application logic been tested without database? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I have a bunch of action methods inside my controller each with its own model binded as input parameter es ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
...