|
I always use a DataReader, never a DataAdapter or DataSet. In my opinion, DataAdapters, DataSets, and DataGrids were developed to allow Microsoft presenters to very quickly query, display, and update simple data and get an "oooh" from the crowd. They are fine for prototyping, but are not suitable for production enterprise applications. DataAdapters are very limited in what they can do and actually try to do too much -- e.g. optimistic concurrency[^].
The few times I've been lazy and used a DataAdapter in a real scenario, it bit me and I had to rework the code to use a DataReader instead.
Also, bear in mind that in ADO.net, all data access goes through a DataReader -- ExecuteScalar, ExecuteNonQuery, DataAdapter.Fill, and DataAdapter.Update all use ExecuteReader to perform the tasks.
ExecuteReader can be used to execute any SQL statement your database accepts -- queries, DML, and DDL. And, in some cases (SQL Server) you can pass a semi-colon delimited list of SQL Statements (though it doesn't report the results of non-queries the way I'd like ).
By using a DataReader you can reduce your application's memory footprint when you don't need to have all the records in memory at the same time. Or you can fill a collection of custom objects rather than a DataTable. Or you can fill a DataTable your own way and avoid the DataAdapter's overhead.
DataGrids and DataGridViews are rarely an appropriate control for displaying and editing data in real situations.
|
|
|
|
|
Hi Everybody
We have one Asp.net application developed using framework 2.0 with C#,Sql and AJAX. The application is running live from past 2 years almost. All the times users will be facing kind of strange problem, reporting some junk data will be displayed on the browser some times. When they refresh the page or reopen the browser, it will display the correct information.
For Eg. We have a stored procedure which returns months between 2 dates, if we pass 2 dates as '01/04/2010' and '30/06/2010' then procedure will return 'APR,MAY,JUN'.
One case we have noticed where it has returned and displayed as MAY,JUN,JUL,AUG which is not possible. Once we refresh or reopen the page it displays the correct information.
This is one ex. whereas we have some other page also where we get unwanted values like that.
If any one has come across such scenario ever, let me know what could be the problem and solution for this.

|
|
|
|
|
devkranth wrote: which is not possible.
Well, it evidently is possible...
Are you saying that it is data returned from this SP that is apparently wrong - or are their other areas on the page that may be wrong?
It sounds to me like a caching issue, maybe? Like, maybe an earlier call to the SP returned the May_Aug list and it is being displayed from a cache?
Using Ajax I have had situations where the customer shows me screens which show incorrect data - which turns out to be something that hasn't finished refreshing through an Ajax call; in this instance I changed the display to be hidden while updating, so it was clear what was happening when the Ajax call was slow.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Thanks Maxxx
Yes, there could be other area on the page also where it is possible.
There is no possiblity of SP returning May_Aug through earlier call as there is no pro data available for this. Only APR-JUN , APR-SEP or JAN-MAR is possible.
For this particular page as it is being used for printing information we have not used AJAX.This problem is reported by the user rarely so it is very difficult to trace out.
The doubt what i have..Can sql responce be modified through network or any other source?
|
|
|
|
|
Could there be some internationalization issue? Date formats vary terribly, and some systems do inconsistent conversions.
Could you show us your function for getting the month names? That could help to figure out what is going wrong.
|
|
|
|
|
Well Thanks Bernhard .This is my Procedure Wat i Have Written
ALTER Procedure[dbo].[sp_ListofMonths]
@FrmDate varchar(20),
@ToDate varchar(20)
AS
Begin
set dateformat dmy;
declare @dateDiff int,
@mon int,
@year int,
@Tmon int,
@TYear int,
@i int
set @mon = month(@FrmDate);
set @year = year(@FrmDate);
set @Tmon = month(@ToDate);
set @TYear = year(@ToDate);
set @dateDiff = datediff(m,@FrmDate,@ToDate)
set @i = 0;
delete from tblMonthList;
while(@i <= @dateDiff)
begin
if(@year <= @TYear)
if(@mon != 13)
begin
insert into tblMonthList(mon,yer) values (@mon,@year)
set @mon = @mon + 1;
set @i = @i + 1;
end
else
begin
set @mon = 1;
set @year = @year+1;
end
end
select
CASE mon
WHEN 1 then 'JAN'
WHEN 2 then 'FEB'
WHEN 3 then 'MAR'
WHEN 4 then 'APR'
WHEN 5 then 'MAY'
WHEN 6 then 'JUN'
WHEN 7 then 'JUL'
WHEN 8 then 'AUG'
WHEN 9 then 'SEP'
WHEN 10 then 'OCT'
WHEN 11 then 'NOV'
ELSE 'DEC'
END,
mon,yer from tblMonthList
end
exec sp_ListofMonths '01/04/2010','30/06/2010'
|
|
|
|
|
What about two (or even more) users accessing tblMonthList at the same time? That would surely result in junk data.
|
|
|
|
|
There is no possiblity of SP returning May_Aug through earlier call as there is no pro data available for this. Only APR-JUN , APR-SEP or JAN-MAR is possible.
Moreover we are facing this junk data problem only for this report (where we have used one temp table tblMonthList) but other places on page load we face this issue.
We are facing this issue on couple of other applications also which is hosted on the same server.
|
|
|
|
|
Hi All, I am trying to do some graphical thing in my window application (VS 2010). What I am trying to do is I need to have a object that shows different states while the application is running. The best example I can give you a elevator. Its door open, close and run etc.I don't know what to use at this point.
Any idea will help.
Thanks.
|
|
|
|
|
if your app is going to paint the frames, this[^] could guide you.
if all you need is a movie, you could turn a number of images into a single animated GIF, and a PictureBox would know how to display that (it is about the only thing it does well).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc Pattyn wrote: (it is about the only thing it does well)
Hey... it's also very good at cluttering up the toolbox I'll have you know!
Illogical thoughts make me ill
|
|
|
|
|
I can't stand animations; they just look like they're wasting cycles that are better used to get the job done. Progress bars are OK. Status indicators are OK.
|
|
|
|
|
Progress bar does not show exactly what I am looking for as I mention in my question. But I don't know how status indicator works. I will give a try.
thanks for your answere.
|
|
|
|
|
jashimu wrote: I don't know how status indicator works.
I mean like a simple red-light/green-light indicator that (usually) doesn't change very frequently.
|
|
|
|
|
I'm not clear exactly what you are after, but have you thought about using WPF which provides you with animation techniques which may suit your needs?
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
_Maxxx_, you are right but the application is in Winform not in WPF. if it was then I could use story board to do that. thanks for your suggestion anyway.
|
|
|
|
|
I want to question how to embed variable value in sqldatasource session parameter in c#. This is mycode:
default.aspx:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Ora2011 %>"
ProviderName="<%$ ConnectionStrings:Ora2011.ProviderName %>"
SelectCommand="SELECT ID, CATEGORY_NAME FROM (:INVENT_CATEGORY)">
<SelectParameters>
<asp:SessionParameter Name="INVENT_CATEGORY" SessionField="INVENT_CATEGORY" Type="String"/>
</SelectParameters>
</asp:SqlDataSourc>
C#:
protected void Page_Load(object sender, EventArgs e)
{
string table = "V_INVENTORY"
Session["INVENT_CATEGORY"] = table;
}
When i run this program, i get error "invalid table name". Why i can't embed variable into sqldatasource from session parameter. Thanks for your help
|
|
|
|
|
This would appear to be an ASP.NET question.
I must get a clever new signature for 2011.
|
|
|
|
|
|
Hi,
I have to return corresponding country currency from a function.
I have a disctionary like Dictionary<string,list<string>> that will contain like:
Dictionary<string,list<string>> str = new Dictionary<string,list<string>>();
List<string> currency= GetCurrency();//Will return all currency stored in database.
str.Add("Currency",currency);
Now currency list contains only currency. I would like to add corresponding country also.
I know that I can create datatable,change the dictionary value to DataTable/DataSet type and return..
Datatable is heavy object...So is there any other approach to achieve this?
Many thanks.
|
|
|
|
|
Hi,
1.
you should use PRE tags to show code snippets, and HTML-escape all < and > and & signs to make them show properly.
2.
this would be pretty close to what you want:
Dictionary<string,string>currencies=new Dictionary<string,string>();
string country="Belgium";
string currency="Euro";
currencies[country]=currency;
EDIT recased some /EDIT
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, February 22, 2011 12:48 PM
|
|
|
|
|
your really going to post code that mixes case of local variables to help answer a question?
|
|
|
|
|
yes it seems I have been on the wrong casing track. All fixed.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
hi! m doing a project in c#. if i say 'D drive' it opns my d drive if i say 'notes' it opns the folder notes from d drive.(i have add the 'D drive' and 'notes' in gramer)
but i want to make gramer general i mean if it is in som other pc and should knw what is all in D drive(Drive can b change i use it for my convenient). and what ever the user say it should opn it. how can i make grammer general. one solution is whnever i run the program it should load the contents of D drive. but how? any other solution?
hope it is clear.
|
|
|
|
|
Good luck. There is a huge amount of effort by very intelligent people to work on voice recognition systems.
I know the language. I've read a book. - _Madmatt
|
|
|
|