.net DataReader Execution Technique
Jan 3, 2010
I heard that DataReader works on forward only readonly fashion and at a time it willread a single record.Suppose when i execute the below code
SqlDataReader reader=cmd.ExecuteReader();
gv1.DataSource=reader;
gv.DataBind();
How the does the gridview populate all records?.As the reader is capable of reading one row per read,I thought only the last row is available for GridView to display.
View 3 Replies
Similar Messages:
Nov 15, 2010
I'm having a method that exports content from the database to excel files. The method taks as paramaters a DataReader param and a int param - the number of rows. For the number of rows i'm using a dataset, wich i fill using the same query as for the datareader. So I'm executing it twice... Is there a way I can avoid that? get the number of rows from the datareader?
View 1 Replies
Jul 28, 2010
I am getting an error that an open DataReader associated with this Command, when I'm not using datareader(though probably executereader() is the same thing) how would I close this if I don't have a datareader present?
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("spSelectAllTypes",conn);
cmd.CommandType = CommandType.StoredProcedure;
[code]...
I just want to be able to databind a bunch of dropdownlist in one open connection. (before I had multiple open and closes for each control)
View 2 Replies
Apr 20, 2010
Nifty and free asp.net controls that replicate the following databinding technique? [URL]
View 11 Replies
Aug 17, 2010
I would like to secure any URL below the http://MyServer/Admins and limit it to a specific role.
In webforms it was straight forward. I just put a child web.config in the /Admin/ folder and add <authorization> <allow roles> tags to it.
How would be the equivalent technique in MVC?
View 5 Replies
Oct 1, 2010
i have table contain two column id and word .word column may contain one word or two or three ex ( computer , computer software , computer software computer )i want search the text if it contain any word in that table .
View 2 Replies
Apr 19, 2010
Which technique is used in handling multilingual implementation? What is the best way to implement it?
View 3 Replies
Feb 27, 2011
In my new ASP.NET EF4 project, I find myself having to do a lot of maneuvering around null entities. For example, I may have a Project Entity with a related User Entity exposed through an Assignee property. Suppose I need to send an email to someone indicating who the Assignee is, I need to say:string x = "The Assignee is: " + TheProject.Assignee.Name;but I'll get an exception if there is no Assignee as the property is null (I want nulls by design) and I can't fetch the .Name property on that null.
View 4 Replies
Sep 4, 2010
I need to highlight active link in the menu. My menu is in the master page by the way. I'm looking for the best way to implement this?
View 3 Replies
Mar 9, 2010
I am looking at a design pattern which has come up in quite a few of my firm's projects.It has historically functioned correctly, however I have heard some other developers argue that there is a possibility of session corruption using this pattern. I'm looking for insight from other .NET developers here on Stack Overflow. Basically, there's a class -- usually either static or a Singleton pattern, depending largely on the developer who wrote it -- stored in App_Code.This class encapsulates access to the current session via properties.All of these properties take the form of:
[code]...
However,because this is just a static entry to HttpContext.Current.Session,it seems like it should be safe, as it is not fundamentally any different than the Page class encapsulating this in the Session property.As I said,no other site on which my company has worked that used this pattern saw it ever have any issues -- and that includes some pretty large and highly active userbases.But I want to just get a fresh perspective.
Are there potential multi-user issues, race conditions, or other failings/flaws which specifically could cause session corruption in the above pattern?
View 2 Replies
Aug 30, 2010
What's the best technique to hide part of a view depending of the credentials of the user?
To explain my self little better and as example i have the following code in my view:
<%= this.Model.Name %> <%=Html.ActionLink("Edit",....)%>
And i would like to hide the edit button for those that aren't administrators for instance...
Could you give me a hand?
View 2 Replies
Feb 24, 2010
I am working on a project that uses data scraping technique to retrieve some url links. I encounter this problem when i pass in the url of a [previous page button] link frm the html code and pass it in to httpWebRequest, the httpWebResponse that i get back is different form the actually content. i have been try to sovle this problem for days and no result, as anyone encounter similar problem and manage to sovle it? below is my sample code: [previous page button] [URL] note: i have change the domain name to a dummy address which is localhost
[Code]....
View 1 Replies
Feb 12, 2011
I have a repeater with about 100 rows, and 4 columns in each row. something like this table:
Username HasIpod HasGymMembership HasCar
``````````````````````````````````````````````````````````````
User1 chcekbox checkbox checkbox
User2 chcekbox checkbox checkbox
User3 chcekbox checkbox checkbox
User4 chcekbox checkbox checkbox
well, you get the idea.The admin can tick/untick any box anytime and click on a "Save" button at the end of page and thats when I need to update the database. I need to add a row in one of the table if a certain checkbox is checked, delete it if its unchecked.I can just loop through the repeater and VERY EASILY do it with each row. but my concern is that, at the worst case, this will use about 100 rows X 3 = 300 database accesses. Thats bad right?I thought of concatenating all values into a form of csv.. something like:user1id,1,0,1;user1id,0,1,1just a list of userid, its values separated with , and the next user's values separated with ; and in the database I can just use a split function and a bunch of while loop and update accordingly.but It just doesnt satisfy me for some reason. Is there a better way to deal with a such a situation? I am sure this is not a unique case, what do you guys do in a scenario?
View 4 Replies
Sep 9, 2010
Is there a jQuery technique to select all the page controls/divs with a non-zero scrollbar position?
I'm trying to solve a problem faced by many; essentially after a partial asp.net postback all the controls/divs that had a scrollbar with a non-zero value (ie: were scrolled down to some position) are reset to the zero (top of the scrollbar).
My approach is to have a jQuery script save all the scrollbar positions for all the controls/divs contained on a page and after the postback, restore all the scroll bar positions.Is it possible, can it even work? If it is, how do I use jQuery to select all the divs with scrollbars and then save those positions.
View 2 Replies
Jan 19, 2011
i have my own DLL (for the data access layer),,i use escaping characters technique to avoid the user input errors ,, but recently i decided to enhance my classes and using parametrized query to prevent all possible errors,Is the modification will be easy or difficult ??how to convert this way to use the parametrized query ..
View 1 Replies
Jan 14, 2011
I have Master Page and ascx user controls in my application.
how would I use the Cross-Page technique using the @ PreviousPageType directive.
useful links or samples to achieve this.
I am trying to use the Page class that exposes a property named PreviousPage from my User Control.
View 3 Replies
Nov 19, 2010
I am working with Parametrized Crystal Reports. There are only two page called Source.aspx and Target.aspx.
[code]...
Only One text box data shows Not 2nd One.Can any one help me with this by checking my code?
View 2 Replies
Mar 30, 2011
I have the following code which does what it's supposed to do:
objSQLCommand = New SqlCommand("select * from table1", objSQLConnection)
objSQLCommand.Connection.Open()
objSQLDataReader = objSQLCommand.ExecuteReader()[code]....
But I need to loop through the objSQLDataReader 1 more time. How would I do that?
View 2 Replies
Mar 23, 2010
how we can serialize a datareader in webservices.
View 1 Replies
Dec 1, 2010
What is the difference between DataSet and DataReader in Asp.net with Example..
View 11 Replies
Mar 20, 2010
How to serialize the DataReader in webservices in asp.net?
View 4 Replies
Aug 17, 2010
Lang-ASP.net using C# and Sql server 2005
i m trying to use the sql datareader to fetch a single row at a time i wanna know can we use it to fetch a single row at a time or not if yes i m unable to figure out what i m doing wrong here bcus its not returning any data
[Code]....
of course data is present in my table bcuz when i m using dataset i m able to the return the single row throuugh dataset
View 3 Replies
Feb 17, 2011
In C#.I have a list<object>.
I want to convert any datareader result (with data) to a list of objects.
How can I do that?
View 6 Replies
Nov 1, 2010
Why can I not call the global variables CatCode and CompanyName which are equated in the first procedure GetCompanyCatID And use their new values in the second procedure UpdateCompanyCounts as parameter values. When I hard code them code their values at the end of the GetCompany CatID procedure the following procedure updates properly.
string CatCode; - delcared global
string CompanyName; - delcared global
protected void GetCompanyCatID()
{
LinkID2 = Request.QueryString["linkid"].ToString();
string L_ID = LinkID2;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString001"].ConnectionString);
SqlCommand cmd = new SqlCommand("GetCID", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@L_ID", L_ID);
try
{
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
if (reader["CG_ID"] != System.DBNull.Value)
CatCode = (string)reader["CG_ID"];
CompanyName = (string)reader["CG_Name"];
}
}
}
catch (SqlException exc)
{ }
finally
{ con.Close(); }
// ******* HARD CODED to test below update procedure, it works. When commented out the following update procedure does not update.
CatCode = "55555"
CompanyName = "Test";
UpdateCompanyCounts();
}
protected void UpdateCompanyCounts()
{
LinkID2 = Request.QueryString["linkid"].ToString();
string L_ID = LinkID2;
string CatCode2 = CatCode;
string CompanyName2 = CompanyName;
// string CatCode2 = "23456";
// string CompanyName2 = "TEST";
SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString001"].ConnectionString);
SqlCommand cmd2 = new SqlCommand("UpdateCatCounter", con2);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@L_ID", LinkID2);
cmd2.Parameters.AddWithValue("@CG_ID", CatCode2 );
cmd2.Parameters.AddWithValue("@CG_Name", CompanyName2 );
try
{
con2.Open();
cmd2.ExecuteNonQuery();
}
catch (SqlException exc)
{
// ErrorBox.Text += string.Format("Error: {0}<br/>", exc.Message);
}
finally
{
con2.Close();
}
}
View 5 Replies
Apr 22, 2010
I've got a static class containing a static field which makes reference to a wrapper object of a DataContext.
The DataContext is basically generated by Visual Studio when we created a dbml file & contains methods for each of the stored procedures we have in the DB.
Our class basically has a bunch of static methods that fire off each of these stored proc methods & then returns an array based on a LINQ query.
Example:
public static TwoFieldBarData[] GetAgesReportData(string pct)
{
return DataContext
.BreakdownOfUsersByAge(Constants.USER_MEDICAL_PROFILE_KEY, pct)
.Select(x => new TwoFieldBarData(x.DisplayName, x.LeftValue, x.RightValue, x.TotalCount))
.ToArray();
}
Every now and then, we get the following error:
There is already an open DataReader associated with this Command which must be closed firs
This is happening intermittently and I'm curious as to what is going on. My guess is that when there's some lag between one method executing and the next one firing, it's locking up the DataContext and throwing the error.
Could this be a case for wrapping each of the DataContext LINQ calls in a lock(){} to obtain exclusivity to that type and ensure other requests are queued?
View 3 Replies