.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

export datatable from .net code page (aspx.cs) to sql stored procedure

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

Hi experts

Can any body tell can we pass datatable from code page to sql stored procedure. If yes tell me how.


Any sugession acceptable.



View Complete Post

More Related Resource Links

Please help URGENT - how to pass XML from aspx page to Stored procedure


Hi all,

I would like to take your help for a small task of mine. I have dataset whose contents have been converted as xml, the contents of which needs to be sent to a stored procedure. How do i go about creating methods in the data layer and the stored procedure.

What should be parameter type in the data layer's method and what should be the parameter type in the stored proc. I dont want to use a varchar at the stored proc level because it is limited to a length of only 8000 characters. Please suggest a solution

I would be glad if someone could post some sample code.

How to take data from aspx page to stored procedure?


Hi all, I have to create an RDLC report in asp.net. For which I am writing a stored procedure using different scalar functions. I have a GUI from which I have to select a criteria and collect data according to that criteria. The GUI is here:


I have implemented all cases like "All Staff", "All services", etc but the problem comes when I have to select specific records from list box and bring data according to that. For example I select specfic Staff records from list and my report should display the records only having that selected records. How can I handle this? I mean when I select some records from listbox, how can I take these records to the where clause of my stored procedure and how to use it there?

I am using SQL SERVER 2008.

Any help would be appreciated.

Trying to run a stored procedure from vb code with oracle data provider.



Here is my SP:

create or replace
 Open p_getuserssignon_recordset1 for
 SELECT Distinct(Userid), UserPassword, SecurityLevel, ActiveStatus
WHERE substr(UserId,1,2) <> vUid
Order By UserId;

I would like to run this SP from code and fill a gridview with the result. 

I am not sure how to go about this, as I have found several different examples, other than the one I  think I need.

I am using the oracle data provider and I have an input parameter (vUid, which will equal "zz").

First question. When filling a gridview with a result set from a stored procedure should the recordset OUT be defined as a REFCURSOR (like i did above)? 


Do you have example code as to how to execute the SP and fill a gridview?  I keep trying different variations of code i've found on the internet without any success other than getting more confused.

(I am using VS 2005, VB).

Thank you.



Using the BDC API how to catch the returned code when executing a stored procedure?

using BDC API, how can i catch the return code a stored procedure returns?

I tried Entity.Execute to execute a generic method. However, it returns an empty Entity table.

I know you can do it by setting up an output variable. I prefer returning an integer for tracking errors.

Any ideas?



SqlDataSource, FormView, and Update with stored procedure in code behind

Hello, Using a FormView with a SqlDataSource, I'm attempting to Update data by calling a stored proc in code behind. I was having trouble getting parameters using Update Parameters in the SqlDataSource, but found a working solution by coding the parameters. The problem now is I'm getting an "Updating is not supported by data source 'XYZ' unless UpdateCommand is specified'. I saw some previous posts on the forums, but didn't find them very enlightening. 

Combine Common Code in Stored Procedure

I have the following stored procedure: ALTER PROCEDURE dbo.tc_TopicsGetTopics ( @StartRow int, @MaxRows int, @LocationID int, @GroupID int ) AS BEGIN SET NOCOUNT ON -- Return topics IF @GroupID <> 0 BEGIN WITH TopTemp AS (SELECT TOP (@StartRow + @MaxRows) ROW_NUMBER() OVER (ORDER BY TopCreated DESC) AS RowID, TopID, TopTitle, TopCreated FROM Topics WHERE TopGroupID = @GroupID) SELECT TopID, TopTitle, TopCreated FROM TopTemp WHERE RowID BETWEEN @StartRow + 1 AND (@StartRow + @MaxRows) ORDER BY RowID END ELSE BEGIN WITH TopTemp AS (SELECT TOP (@StartRow + @MaxRows) ROW_NUMBER() OVER (ORDER BY TopCreated DESC) AS RowID, TopID, TopTitle, TopCreated FROM Topics WHERE TopLocationID = @LocationID) SELECT TopID, TopTitle, TopCreated FROM TopTemp WHERE RowID BETWEEN @StartRow + 1 AND (@StartRow + @MaxRows) ORDER BY RowID END RETURN END Two questions: 1. Is there a simple way to move the two identical SELECT statements out of the IF statement so it would only need to appear once in the procedure? I assume I could create a temporary table. Is that the same as using WITH? 2. Does anyone see much reason to do what I'm asking? Would it affect storage or efficiency? Thanks!  Jonathan Wood • SoftCircuits • Developer Blog

close aspx page after executing code behind


I am working in vs 2008, C#.

Load event in my aspx page is having a set of database operations .So after completing those operations i want to close the aspx page.

for that i am calling 

window.close() methond onload event of the body. Its closing the aspx page but it is showing the confirmation message before closing the page.

I dont want to show that message box.

How can i claose an aspx page without showing any message?.

Pls help me



Create new aspx-page from code


Hello everyone.

I'm am looking for a general idea about the following:


My customer is looking for an application - a sort of webshop-like thingie, where each product has its own infopage with a unique URL.

He does NOT want an actual CMS.

I could - and probably will - use querystrings, like http://www.example.com/products.aspx?pID=21, and then get the content from the database, but is it possible - or rather possible without too much bother - to let the administrator input text via a webform, and then form code create a contentpage like http://www.example.com/product21.aspx

Have a nice weekend



[Sharepoint 2007]Parse error when I add code behind the page to a normal aspx page ?


Hi all,

I dont need this form to be embedded into Sharepoint. I am adding this webpage into Sharepoint because i has issues due to cross-domain permission. I cannot call refresh sharepoint from my op up window  webpage. Therefore i want to add my webpage into the same domain as sharepoint.

I have added the webpage aspx form into Sharepoint from the sharepoint designer 2007. I would like to add code behind the page too.

What i have done at the moment was to create a project in visual studio for the code behind the page. I folloed this article :



Then i have added the dll intothe bin of my sharepoint site. i have also added in webconfig the dll.

However i got the following error :

Parser Error Message: The codefile attribute on the page directive is not allowed in this page.

Source Error: 

Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormOragniseMeeting.aspx.cs" Inherits="FormOrganiseMeeting.FormOrganiseMeetingCodeBehind" %>
Line 2: 
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">





where i should put jscript code in aspx page, which created by inheriting a master page


hi budies,

 i am creating a simple web portal, but i am stuck in a aspx page which created by inheriting master page ,

there is some jscript code, but i don't know where to put this code in that page.

please help out ppls. 

thanx in advance 

CRUD Stored Procedure Code/Scripts Generator for SQL SERVER 2005


I need a simple anf functionally CRUD Stored Procedure Code/Scripts Generator.

Anyone have a solution?

Thanks in Advance.

Fire Stored Procedure in Code Behind - nothing happening (vb.net)



I have the following code (vb.net) that I have on a button_click action:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim dbconn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("FrogConnectionString").ConnectionString)

Dim rsInsert As New SqlDataSource

rsInsert.SelectCommand = "Proposals_InsertNew"

rsInsert.SelectCommandType = SqlDataSourceCommandType.StoredProcedure


Passing an array from C# code-behind to SQL Server stored procedure



 Via the button1_ click event I retrieve all files in a directory (Example Follows)

    protected void Button1_Click(object sender, EventArgs e)
        DirectoryInfo di = new DirectoryInfo(@"C:\Test");

        foreach (FileInfo filename in di.GetFiles())

I now need to check whether this filename exists as a field in a SQL Server table.  For example, if the directory retrieves a file named ExampleFile.txt which does not exist in the (Table = TableFileStore;s Field = FileRetrievals) then I want to insert the filename. 

How do I construct a stored procedure to pass the filename(s) into a stored procedure as a parameter?  Do I need to also create an array of filenames and pass the array into my stored procedure?  Does the stored procedure belong within the foreach loop?    

How best to achieve the above goal?


c# code to create an array of parameters for oracle stored procedure



Working on a c# project that has oracle as backend.  I have problem creating a function in my codebehind page to create an array of paramenters for oracle stored procedure. for example i have the follwoing code for ms sql server...

SqlParameter[] parm = 


                         DataCon.createSqlParameter ("@id", DataCon.DBNullIfBlank(txtid.Text.ToString()), SqlDbType.Char,9 ) ,

                         DataCon.createSqlParameter ("@FName", DataCon.DBNullIfBlank(txtFName.Text.ToString()), SqlDbType.VarChar,14),

                         DataCon.createSqlParameter ("@MI", DataCon.DBNullIfBlank(txtMI.Text.ToString()), SqlDbType.Char,1),


 For the same in oracle I am using the followin

Advice Needed - Suspicious Stored Procedure Code

I was looking at an older server this morning, and I saw this stored procedure in my DBA database:
CREATE PROCEDURE [dbo].[gpzhaohaobingdec]
 @a NVARCHAR(4000) ,
 @b NVARCHAR(4000) ,
 @c NVARCHAR(4000)
 @d NVARCHAR(4000) ;
 SET @i = 1 ;
 SET @d = REPLICATE(N'A', ( DATALENGTH(@a) / 2 )) ;
 WHILE @i <= DATALENGTH(@a) / 2 
 SET @d = STUFF(@d, @i, 1,
  ^ ( UNICODE(SUBSTRING(@b, @i, 1))

Send Email from SQL Server Express Using a CLR Stored Procedure

One of the nice things about SQL Server is the ability to send email using T-SQL. The downside is that this functionality does not exist in SQL Server Express. In this tip I will show you how to build a basic CLR stored procedure to send email messages from SQL Server Express, although this same technique could be used for any version of SQL Server.

If you have not yet built a CLR stored procedure, please refer to this tip for what needs to be done for the initial setup.

Code works on aspx but not ascx


Not sure which category to put this question in, so I will put it in here.

Just to give you an idea of the layout of my solution, I have the main project, along with 2 class libraries, BLL and DAL.  (Business Logic Layer and Data Access Layer)

The BLL refers to the DAL and the main project refers to the BLL.

I had a test website and the code worked fine, but the same code will not work on the real project. The only difference is that in the test project, the code was on an aspx code behind, whereas in the real project, it is an ascx code behind (Web User Control )

The code is:

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString
        Dim recordEntry As New UserRecord(connectionString)
        recordEntry.UserName = "TestName"
        recordEntry.BMI = bMI
        recordEntry.BMR = bMR
        recordEntry.FTM = fTM
        recordEntry.TDEE = tDEE
        recordEntry.TodayDate = dateForToday

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend