Javascript - How To Call Stored Proc From MVC Stack Via The ORM And Return Them In Json

Mar 29, 2010

i'm a total newbie with mvc and here's my jam:

i have a 3 level list box which selection on box A shows options on box B and selection on box B will show the options for box C.

I'm trying to do the whole thing in MVC and what i see is that the nerd dinner tutorial uses the ORM method.

so i created a dbml to the database and drag the stored proc inside. i create a datacontext object but i don't quite know how to connect the result from the stored proce which should be multiple rows of data and make it into a json. so i can keep all the json data inside the html page and using jquery i could make the selection process faster. i don't expect the data inside the three boxes to change so often thus i think this method should be quite viable.


So how do i get the stored proc part
to return the data as json?
i've noticed some tutorial online
that the json return result part is
at the controller and not at the
model end.
Why is that?
FYI, i find what i mostly wanted to do here.
For the json part, i referenced here.

View 1 Replies

Similar Messages:

C# - Stored Proc In Sql That Does Not Return The Value

Sep 9, 2010

My function isn't returning anything - strReturn is empty:


When I execute this stored proc using 'exec GetMerchantLocationZip (3333, 373773)' I get the correct zipcode in SQL. Why don't I get it in Visual Studio?


I am learning, so apologies if it's a obvious error.

View 7 Replies

SQL Server :: Stored Proc & Assigning Its Return Parameter Value To A Variable

Aug 1, 2010

I have a stored proc. that returns the USL & LSL values for each of the 8 different Metrics. say, Defect Density (Upper Specification Limit) USL = 0.30 & Defect Density (Lower Specification Limit_ LSL = 0.05). Simillarly for 8 different Metrics. Why I need these Spec. Limits ?...Because I want o compare my project's Metrics Value displayed in the Grid View with the corresponding USL & LSL value of the same Metrics. IF Metrics Value is outside of USL & LSL Then I want to Mark the Metrics in Red Color.

1. STORED PROC "Get_Spec_Limits" Does Not Return Anything
2. Error : Object Reference Not set to an Instance of an Object, in the following "OnRowDataBound' Event

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim strConnection As String = "Data Source=******;Initial Catalog=Metrics;Integrated Security=True"
Dim objConnection As New SqlConnection(strConnection)
Dim da As New SqlDataAdapter("Get_Spec_Limits", objConnection)
da.SelectCommand.CommandType = CommandType.StoredProcedure
Dim Productivity_USL As New SqlParameter("@Productivity_LSL", SqlDbType.Float)
Dim Productivity_LSL As New SqlParameter("@Productivity_LSL", SqlDbType.Float)
Dim IDD_LSL As New SqlParameter("@IDD_LSL", SqlDbType.Float)
Dim IDD_USL As New SqlParameter("@IDD_USL", SqlDbType.Float)
Dim EDD_LSL As New SqlParameter("@EDD_LSL", SqlDbType.Float)
Dim EDD_USL As New SqlParameter("@EDD_USL", SqlDbType.Float)
Dim DRE_FS_LSL As New SqlParameter("@DRE_FS_LSL", SqlDbType.Float)
Dim DRE_FS_USL As New SqlParameter("@DRE_FS_USL", SqlDbType.Float)
Dim DRE_TS_LSL As New SqlParameter("@DRE_TS_LSL", SqlDbType.Float)
Dim DRE_TS_USL As New SqlParameter("@DRE_TS_USL", SqlDbType.Float)
Dim DRE_Code_USL As New SqlParameter("@DRE_Code_USL", SqlDbType.Float)
Dim DRE_Code_LSL As New SqlParameter("@DRE_Code_LSL", SqlDbType.Float)
Dim COQ_USL As New SqlParameter("@COQ_USL", SqlDbType.Float)
Dim COQ_LSL As New SqlParameter("@COQ_LSL", SqlDbType.Float)
Dim COPQ_USL As New SqlParameter("@COPQ_USL", SqlDbType.Float)
Dim COPQ_LSL As New SqlParameter("@COPQ_LSL", SqlDbType.Float)......................

View 4 Replies

DataSource Controls :: DBNull Error Trying To Call Stored Proc?

Jan 7, 2011

I have a recordset in a gridview that comes from an outer joint that creates null values in the recordsetWhen I write to the database using stored proc defined in datasource I get dbnull error.I'm trying to process the onDeleting event in the code behind but don't know what to write or if that's the best wayI need to call a stored proc and if the last parameters value is null then the stored proc does one thing, if it's no null it does something else.However DBNull doesn't ssem to be working.

View 1 Replies

SQL Server :: Pass Stored Proc Output To Another Stored Proc?

Jul 28, 2010

i have two stored procs. when th 1st stored proc runs i want to be able to use this value returned from the stored into another stored proc.

my first stored proc is:


which returns [Transfer_stations_Authority_name] = 'Blackpool'

now i want to use this value into my second stored proc@



View 1 Replies

Make A JQuery Ajax Call To A Webservice That Needs To Return JSON

Jun 19, 2010

Actually I am trying to learn jQuery Ajax calls to asp.Net webservices.

I have been trying to call the webmethod below:


Do I need to serialize my object in some way before setting the 'data' attribute, so that I can call $.ajax() function?

View 2 Replies

DataSource Controls :: Call The Stored Procedure And For It To Return A True Or False?

Aug 4, 2010

Am stuck with this sql stored procedure/ vb.

I want to call the stored procedure and for it to return a true or false if successful ie username and password match.

My stored procedure works fine, and I can call it from my vb, however I stuck as to how I get it to return a result of true or false, 1 , 0. I just get a blank page.

My Codebehind ( vb):


View 1 Replies

JavaScript - Can Handle Both Json And HTML Datatypes In The Same Ajax Call

Mar 2, 2011

Is there anyway I can handle both json and html return types when posting jquery ajax:

For example, this ajax call expects html


View 1 Replies

Javascript - AJax JSON Call Error When Trying To Access The Properties Of Class

Oct 7, 2010

I am making a JSON call to web method which is defined in code behind. The web method returns a class object.The class returns 3 properties one of type list and 2 integers. I am accessing these in the following manner:

success: function(result) {
if(result.LookCount > 0)
var Info = "";
for(var i = 0;i < result.LookUps.length; i++)
Info += CreateLookUpGrid(result.LookUps[i].Client,result.LookUps[i].ClientOrg);

alert(result.LookCount) -> alerts undefined and when i alert result it shows me the compelte result string which has all data. So the data is returned correctly by web method. But I am unable to access it.

View 2 Replies

Javascript - How To Make Json Child Nodes (JSON Inside JSON)

Aug 11, 2010

I try to use the jquery + json to get all elements in form and build a JSON var to post in a ASP.NET MVC method.


It method get all fields in a form and build a JSON, but it dont put JSON inside JSON.


If i have the follow form:

<input name=""><input name="person.age"><input name="person.address.street">

The serialized string build a JSON like this

{ "": "??", "person.age": "??", "person.address.street": "??" }

I need a plugin or some function to generate like this:

{ "person": { "name" : "??", "age" : "??", "address":{ "street": "??" } } }

View 1 Replies

C# - Error When Executing A Stored Proc

Aug 17, 2010

I am attempting to execute a stored proc in in the code behind. The parameter I am trying to pass is strErrorMessage that contains a value of "The transport failed to connect to the server.; ". The error message when the query gets executed is: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@errMessage"): Data type 0xE7 has an invalid data length or metadata length. Update with code

catch (Exception ex)
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email was not sent - " + ex.Message + "');", true);
string strMessage = ex.Message;
string strStackTrace = ex.StackTrace;
strMessage = strMessage.Replace("
", "; ");
strMessage = strMessage.Replace(" ", "");
strStackTrace = strStackTrace.Replace("
", "; ");
strStackTrace = strStackTrace.Replace(" ", "");
AppErrorLog(strMessage, strStackTrace);
return false;
protected void AppErrorLog(string strErrorMessage, string strErrorStackTrace)
SqlConnection conErrLog = new SqlConnection(strConn);
string sql = "usp_AppErrorLog_AddRecord";
SqlCommand cmdErrLog = new SqlCommand(sql, conErrLog);
cmdErrLog.CommandType = CommandType.StoredProcedure;
cmdErrLog.Parameters.Add(new SqlParameter("@errMessage", SqlDbType.NVarChar, 8000));
cmdErrLog.Parameters["@errMessage"].Value = strErrorMessage;
cmdErrLog.Parameters.Add(new SqlParameter("@errStackTrace", SqlDbType.NVarChar, 8000));
cmdErrLog.Parameters["@errStackTrace"].Value = strErrorStackTrace;
cmdErrLog.Parameters.Add(new SqlParameter("@userID", SqlDbType.VarChar, 12));
cmdErrLog.Parameters["@userID"].Value = User.Identity.Name;
SqlDataAdapter ada = new SqlDataAdapter(cmdErrLog);
catch(Exception e)
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('AppErrorLog - " + e.Message + "');", true);

The column datatype in the table is nvarchar(MAX).

View 4 Replies

SQL Server :: Stored Proc And Scope_identity

Aug 3, 2010

i have the following stored proc that inserts data into a database based on a stauts field. the first stored proc inserts into the first table and i am trying to get the identity field out as i need this value for the next stored proc. the first stored proc works fine and inserts the data but the secnd one doesnt, even though there is data there.


View 3 Replies

MVC :: Calling Stored Proc From A Controller?

Jan 21, 2011

I am trying to pass stored procedure from a controller to view. In my Home controller, in Index method, I have this. CustOrderHist is my stored procedure from northwind database.

public ActionResult Index()
DataClasses1DataContext dc = new DataClasses1DataContext();
var products = dc.CustOrderHist("ALFKI").GetEnumerator();
return View(products);


View 3 Replies

ADO.NET ::stored Proc That Takes A Bit Long To Run?

Aug 13, 2010

I have a stored proc that takes a bit long to run. I tried to do this command.CommandTimeout = 200;still gets time out within 200 secs.How is this done?

View 1 Replies

SQL Server :: Raise Error Stored Proc?

Mar 16, 2011

I have written a stored proc for raise error.Whenever a customer checks for a record in the DB that doesn't exist in the DB he has to get an error displayed.I have written a stored proc help me on it i know it is wrong suggest me the correct one.


View 5 Replies

Databases :: How To Execute An Oracle Stored Proc

Oct 14, 2010

ORA-06550: line 2, column 19:
PLS-00201: identifier 'CURSOR' must be declared
ORA-06550: line 2, column 15:
PL/SQL: Item ignored
ORA-06550: line 5, column 45:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored

View 4 Replies

DataSource Controls :: Stored Proc Is Not Working?

Mar 18, 2010

I have made a simple stored proc which include Transaction through which I have to delete records from two tables EmpDetail and EmpDept . EmployeeId is PK in EmpDetail and FK in EmpDept. Procedure has been executed but on doing exec DelEmployee @EmployeeID='e07' showing 0 rows affected..


View 6 Replies

DataSource Controls :: Getting @@Identity Value From Stored Proc?

Jul 2, 2010

I've been self teaching SQL and and i'm a little stuck. I have a stored proc for the insert and then in my Insert inside my class it's not returning the ID after the insert as I am receiving an error message that NULL value has cannot be inserted. I want to add default values to a seperate table after the insert. I will provide my code below, if anyone can help me why the value is not going across?


View 7 Replies

SQL Server :: Stored Proc Insert Into One Table From Another?

Jul 27, 2010

i am trying to write a stored proc that takes data from one table based on a field in that tabke and writes that data out to another table with the eventual idea that this data is deleted from the original table it was read from. my stored proc is as follows:


but i keep getting an error: incorrect syntax near 'BACKUP_TWS_Waste_Colection_Request'.

View 8 Replies

SQL Server :: Updating All Records Using Stored Proc?

Mar 9, 2011

I hope to one day figure this looping records from a table to update it, but i cannot get this to complie, I guess cause I am not

versed in looping in sql yet :(


I just want to get data from a table per record run the stored procedure(i have nesting on) and update the record's fields with the values that were returned from the Store procedure. The Stored procedure is working fine.

View 6 Replies

SQL Server :: XML / Creating An XML File From Stored Proc?

Dec 16, 2010

I'm converting Active X code in DTS to Script Task for SSIS and I'm having trouble creating an XML file from my stored proc. Here's the code:


It throws an error on the dataAdapter fill saying:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '<'.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '<'.
Msg 132, Level 15, State 1, Line 5
The label 'sql' has already been declared. Label names must be unique within a query batch or stored procedure.

View 6 Replies

Databases :: Stored Proc Which Accepts Datatable?

Dec 15, 2010

I want to have a stored procedure which will accept a Datatable from .NET application and the tablename and will loop thru' each record in the Datatable and insert it into the table. It will insert the bad records into a bad file. Also how to send the datatable to the proc,what kind of parameter to use.
Pls post the code for this proc.

View 3 Replies

ADO.NET :: Using Stored Proc In CTP5 Having Multiple Parameters

Mar 4, 2011

I am having a strange problem with using stored proc in CTP5.I am calling a stored proc in my function like this:

private List<Test> GetDatat(Test pTest)
using(var staticDB=new StaticDB()) [code]...

But I am getting error that parameters not found. Looking at the sql trace I can see that CTP5 is sending "default" value if any of my parameters is null instead of the null value.

View 2 Replies

SQL Server :: Calling One Stored Proc From Another In A Query?

Nov 2, 2010

Is it possible to call 1 Stored procedure from another withing a sql query

sp1 :

select ID1,ID2,ID3,ID4 from table1 ;

sp2 :

select name from table2 where ID = ID1;

I want to get corresponding names of ID1,ID2 and ID3,ID4 in sp1 as a query result.Is it somehow possible to call sp2 from sp1?

View 10 Replies

Web Forms :: Unable To Evaluate Expression Because Code Is Optimized Or Native Frame Is On Top Of Call Stack

May 7, 2015

I want to export the data to pdf in which table has 150 columns. 

When i save the file in directory , the file is opening. whereas when open it directly some box type is displaying. 

And also am getting exception in Response.End() method which is given below

"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." 

View 1 Replies

Copyrights 2005-15, All rights reserved