Query Datasource From Code-behind Versus SqlDataSource

Aug 28, 2010

What ive been using now is getting datas in code-behind, passing datasource into a Session, re-binds it to a gridview whenever there's paging/sorting needed. What i want to know is what is better if its performance we are talking about?

Is it datasource into a session Or SqlDataSource for which I know whenever paging/sorting needed is that sqldatasource opens up a DB connection to get the datas again?

View 6 Replies


Similar Messages:

DataSource Controls :: SqlDataSource And Parameters Query / Trying To Accomplish Is Building Dynamic Query

Aug 22, 2010

1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like

SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.

Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).

2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query

(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).

If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.

View 11 Replies

DataSource Controls :: Sqldatasource On Inserting Query?

Jul 15, 2010

I have an editable grid where user can add/edit data. They also have the option to load previously entered data from last month. When the user then clicks save, i want to readd this newly modified data as a new record for this month. So basically I want to call the insertcommand, but it does not work. My 'save' method just 'updates' the records.

Providing sqldatasource, grid and save method
<asp:SqlDataSource ID="SqlDataSourceLoadActivities" runat="server" [code].....

View 4 Replies

DataSource Controls :: SqlDataSource Query Not Working?

Feb 18, 2011

I have a strange problem...I am programatically adding an SQL SELECT query to my SqlDataSource that my GridView is bound to. If I use the follwing statement it works fine:

[Code]....

But if I use the following one, the gridview fails to load. The only way that this is different is it uses RTRIM and CAST on one of the fields:

[Code]....

I don't understand why this can be. If I try the statement exactly how it is in the query builder and run it it returns the rows no problem.

View 2 Replies

DataSource Controls :: Can The Select Command Of A SqlDataSource Be Given By Code In The Code Behind File

Apr 16, 2010

Can the select command of a SqlDataSource be given by code in the code behind file. Also by calling the SqlDataSource.Select can the select statement be executed?

View 3 Replies

DataSource Controls :: Make Parametrized SqldataSource Query In C#?

Jun 10, 2010

I have a gridview which I connect by C# and SqldataSource. I use asp.net 2.0 - 3.5.

I want to parameterized the queries and how do I do this in the C# file ? how do I set the selectparameters in C# ?. I do not want to do this in the aspx fil.

My code in C# is:

SqlDataSourceMachineName.SelectParameters.Clear();
SqlDataSourceMachineName.SelectCommand = "Select MachineName from tblMachine inner join tblLocation on tblMachine.MachineLocationID = tblLocation.LocationID where tblLocation.LocationName = 'New York' and
tblMachine.StatusID = '1'";

View 9 Replies

DataSource Controls :: Breaking Long Query Into Small One Using SQLDataSource?

Oct 25, 2010

Currently, I have long script which does major processing and then puts data into temp table.

Finally I read data from this temp table to show on the chart, based on user's selection of parameter. So I can divide my query into two parts and while I am researching this,

Is it possible to do processing in one Datasource and read table from second datasource?Is it even possible?

If not, what is recommended method for this (breaking large processing into small one)?

View 2 Replies

DataSource Controls :: SqlDataSource Query Not Using Index On Database Table?

Jan 20, 2011

I have this sqldatasource:

<asp:sqldatasource id="SqlDataSourceX" runat="server" connectionstring="<%$ ConnectionStrings:MyConn%>" providername="System.Data.SqlClient"
selectcommand="SELECT ItemNum, MIN(DateAdded) as [DateAdded]
FROM Items WITH (NOLOCK)
WHERE [DateAdded] between @DateFrom AND @DateTo

[Code]....

When I call select in codebehind, after 30sec it throws timeout expired SqlException:

[Code]....

again , this select took up to 3 sec to be executed. In application I tried to use SqlConnection and SqlTableAdapter instead of SqlDataSource, with the same query, and again it took up to 3 sec.

If I choose tighter interval (e.g '2011-01-20 00:00:00' - '2011-01-21 00:00:00') , there is no timeout exception, so I know that sqldatasource select is executed correctly. So the conclusion is that sql server is not using index while executing query sent from sqldatasource, but is using index whenever else. I have also checked the index statistics on sql server and it is like that. In profiler i can see slight difference between this two cases. As for SqlDataSource, in events table, in first column "EventClass" after 30 sec, there is this: "RPC:Completed" and application throws timeout. If i use SqlConnection and SqlTableAdapter then at the same place there is this: "SQL:BatchStarting" and "SQL:BatchCompleted" and application does not throws timeout(the index has been used).

what is so special on SqlDataSource connection, that Sql Server performs differently compared to other types of connections?

View 3 Replies

SQLDataSource Versus ADO.NET

Mar 8, 2011

If I want to connect to a database in ASP.Net, is it better to use ADO.NET rather than SQLDataSource? They serve a similar purpose, correct?

View 7 Replies

DataSource Controls :: Test The Performance Of When The Query Is Included Directly In The SqlDataSource?

Feb 16, 2011

I have a query that I want to test the performance of when the query is included directly in the SqlDataSource versus when I call a stored procedure. Does anyone have suggestions on how I would be able to closely watch the actual steps here? I was thinking of turning on tracing and adding Trace.Write for each of the events that fire along the way. This doesn't seem efficient and I wanted to see if there was a better approach.

View 2 Replies

SqlDataSource Versus ADO.NET Coding With C#

Feb 25, 2011

I really do not have time to learn new language, in my case asp.net, but would like to start developing website in asp.net. I do not want to use asp:SqlDataSource control. is it ok if i write in codebehind aspx: all database connections and other CRUD operations in ado.net and c#. I already know xhtml, javascript - jquery, css, xml, json, some knowledge in sever-side coding (before php). want to start coding, instead of learning messy asp.net controls.I have to sit and learn all bloody ways of using those asp.net controls?

View 2 Replies

Forms Data Controls :: ADO.NET Versus SqlDataSource

Jun 29, 2010

I am developing web-app in .NET for 5 months (and enjoying it =)) and I am reading 3 books, all of them teachs at least 2 methods for acessing data: ADO.NET and SqlDataSource object.

I am used to work with ADO.NET method because I feel that even if it needs coding by hand, I can separate the SQL routines from the page and I can customize database routines better.

For now I am using DataReader mode because the application and the database is on the same server and there is only 1Gb RAM available so there is no advantage using DataSet on this moment.

Am I thinking this right? There are some things with SqlDataSource that I don't know how to do it well...

For example:

I have a routine that inserts a record on a table then gets the ID of this record using SCOPE_IDENTITY() function of SQL Server, than it uses this ID to insert another record on another table. Because I use a one-to-many relationship on multiple tables...

How can I work this situation using SqlDataSource object, is it even possible?

View 2 Replies

DataSource Controls :: If Value In Sqldatasource Is Null Run Code?

May 15, 2010

what i would like to do is when the value of my sqldatasource is returned, then if it is null, run a code, in my case, redirect them to the login page, heres my code:

string connectionString = ConfigurationManager.ConnectionStrings["PokemonPlanetConnectionStrings"].ConnectionString;
string insertSql = "SELECT * FROM LoggedInUsers WHERE UserId = @UserId";
using (SqlConnection myConnection = new SqlConnection(connectionString))

[Code]....

Now what i would simply like to do is, if the select statement searches the database, and the result is not found, the simply redirect them to "register.aspx"

View 6 Replies

DataSource Controls :: SqlDataSource, FormView, And Update With Stored Procedure In Code Behind

Sep 12, 2010

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'.

View 3 Replies

DataSource Controls :: Use Sqldatasource From Code Behind With Datacontrols Like Gridview,detailsview And Formview?

Aug 1, 2010

Is Sqldatasource powerful? Is there any disadvantage using it over other controls?

And How to use Sqldatasource from code behind with datacontrols like gridview,detailsview and formview?

Is it possible to completely customize the gridview using sqldatasource from code behind?

View 6 Replies

DataSource Controls :: Used Sqldatasource For Performing And Update Query But How To Update The Record On Click

Nov 9, 2010

Here is the sqldatasource config code: <asp:SqlDataSource ID="SqlDataSource1" runat="server"

View 1 Replies

DataSource Controls :: SQLDataSource And Tie A SqlDatasource To A Stored Procedure

May 14, 2010

I am trying to tie a sqlDatasource to a Stored Procedure. The stored procedure looks like...

[Code]........

View 2 Replies

DataSource Controls :: How To Create A Query In Gridview Selectcommand Without The Code Behind

Dec 1, 2010

how to query the system date in selectcommand in gridview without using the codebehind. using c# .net

my code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT * FROM tablename where date_today = <SYSTEMDATE>" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName
%>"

View 1 Replies

DataSource Controls :: How To Convert, The Code To Query A SQL Database Using A DSN-less Connection

Sep 10, 2010

How do we convert, the following code to query a SQL database with ASP using a DSN-less connection

[Code]....

View 2 Replies

DataSource Controls :: Sql Query - Get Minimum Price When Pass Parameters - Code Is Duplicating Value

Feb 1, 2010

here is my query which is not working properly. I have 5 fields in my table Company, Reseller, Item, Code, Price. How can i get minimum Price when i pass parameters for Code is dublication value

Company Reseller Item Code Price
A A-1 I1 C1 20
B A-21 I2 C2 13
C A-B I1 C1 19

select Company,Reseller,Item,Code,Min(Price) from Table1 where code='C1' order by Code HOW CAN I GET THIS BELOW TYPE OF RESULT

Company Reseller Item Code Price
A A-1 I1 C1 20
C A-B I1 C1 19

View 17 Replies

Configuration :: Deploying Versus Releasing Versus Implementing

Sep 16, 2010

What is the difference between; Deploying an application Releasing an application Implementing an application

View 1 Replies

Query - Use A Checkbox To Change The Results Of A SqlDataSource?

Feb 2, 2011

I'm using Visual Web Developer 2010 Express. This is my first attempt at creating a .NET page. I have a Gridview on a page that displays the results of a GridQuery. This works. I have a checkbox control(cb_Filter) on the same page that if checked, should add to the where clause of the GridQuery, (where Column5 IS NULL). How do I check the state of the check box so it will run the query with or without the "filter".

View 2 Replies

Pass A GUID To A Select Query Of SqlDataSource?

Apr 3, 2011

I have an SqlDataSource with following command:

SELECT * FROM [vw_aspnet_MembershipUsers] WHERE ([UserId] = @UserId)

When I pass simple GUID like "3bd08871-d5d6-4f38-8c8a-29fd6077a719" as a UserId, then nothing gets selected. So what is the correct format for passing the GUID value?

View 2 Replies

Application_Start Versus OnInit Versus Constructor?

Jul 23, 2010

I've gone rounds with this ever since I started programming classic ASP 12 (or so) years ago and I've never found a great solution because the architecture of ASP and ASP.NET has always been a swamp of bad practices, magic shared singletons, etc. My biggest issue is with the HttpApplication object with its non-event events (Application_Start, Application_End, etc.).

If you want to do stuff once for the entire lifespan of an HTTP application, Application_Start is the obvious place to do it. Right? Not exactly. Firstly, this is not an event per se, it's a magic naming convention that, when followed, causes the method to be called once per AppDomain created by IIS.

Besides magic naming conventions being a horrible practice, I've started to think it might be a reason there exist no such thing as a Start event on the HttpApplication object. So I've experimented with events that do exist, such as Init. Well, this isn't really an event either, it's an overridable method, which is the next best thing.

It seems that the Init() method is called for every instantiation of an HttpApplication object, which happens a lot more than once per AppDomain. This means that I might as just put my startup logic inside the HttpApplication object's constructor.

Now my question is, why shouldn't I put my startup logic in the constructor? Why does even Init() exist and do I need to care about Application_Start? If I do, can anyone explain why there is no proper event or overridable method for this pseudo-event in the HttpApplication object?

And can anyone explain to me why in a typical ASP.NET application, 8 instances of my HttpApplication are created (which causes the constructor and Init to run just as many times, of course; this can be mitigated with locking and a shared static boolean called initialized) when my application only has a single AppDomain?

View 2 Replies

Adding ControlParameter To SqlDataSource Prevents Query And Databinding?

Nov 2, 2010

I have a SqlDataSource that calls a stored procedure and it works fine. If I add a <ControlParameter> tag to add an additional argument, then the query never fires and the databinding never occurs.

This works:

[Code]....

When I add the ControlParameter, the databinding no longer occurs:

[Code]....

The ControlParameter refers to a valid object on the page.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved