|
Hi,
with GemBox.Spreadsheet Excel C# library you can easily convert DataSet to Excel and stream it to browser.
Here is a code snippet how to do it:
var ef = new ExcelFile();
foreach (var dataTable in dataSet.Tables)
{
var ws = ef.Worksheets.Add(dataTable.TableName);
ws.InsertDataTable(dataTable, "A1", true);
}
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=Employee.xls");
ef.SaveXls(Response.OutputStream);
Response.End();
|
|
|
|
|
Wich dataaccess metod is faster - with datareader when the data is return from stored procedures or with LINQ.
What is the difference if is working with milions of records in a table?
Thanks for your answers!
|
|
|
|
|
|
A properly used data reader will always be faster ... since it is of course the most direct method of accessing data in .NET. Data readers are even more efficient if you define indexes for the returned columns instead of using the string look-up method.
|
|
|
|
|
Do you how much faster it will be? Do you have any statistics for example table with 10 milin rows?
|
|
|
|
|
I have a system which I currently maintain that I converted one report from LINQ to the Data reader method. The one report was estimated to have a run time of a week with LINQ (we never let it finish just did timings on subsets) and the data reader version takes 30 seconds. Admittedly the LINQ version could have been cleaned up but LINQ encourages bad code so that needs to be watched for as well. In general
Data Readers with integer column indexes on well written stored procedures: fastest
Data Readers with string column indexes on well written stored procedures: 10x slower
LINQ 20x to 100x slower. Some situations LINQ will be just as fast as data readers but never faster.
You can ignore the size of the database for the discussion. If you want statistics there is someone who did a nice little timing comparison between all of the methods (you can search Google if you want) or you can take my word for it.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: The one report was estimated to have a run time of a week with LINQ
That is possibly a little unfair, I've had 1st draft stored procs that have run times of hours, after a little works and some indexing they get reduced to seconds.
However your point that LINQ encourages lousy code by abstracting another layer is the telling point. How many devs get under the hood of the Linq, or are even capable of doing so!
I'm of the opinion that LINQ is one of the greatest abominations ever to come out of MS.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Look here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I want to have a set of "export" buttons which generates a different type of report when the user clicks any of these, and then prompts the user to download the generated report (let's say that this report is an xls file).
What should I do so that when the user clicks the button, it will not post-back the page and still prompt the user to download?
Is there any control that I can use?
Thanks.
Rafferty
|
|
|
|
|
Global.ASAX
<%@ Application Codebehind="Global.asax.vb" Inherits="AdamItiel.GlobalApp" Language="vb" %>
Global.ASAX.VB
<br />
Imports System.Web.SessionState<br />
<br />
Namespace AdamItiel<br />
Public Class GlobalApp<br />
Inherits System.Web.HttpApplication<br />
<br />
Private Shared userFirstNameVal As String<br />
Public Shared Property UserFirstName() As String<br />
Get<br />
Return userFirstNameVal<br />
End Get<br />
Set(ByVal value As String)<br />
userFirstNameVal = value<br />
End Set<br />
End Property<br />
<br />
Private Shared newPropertyValue As String<br />
Public Shared Property UserLastname() As String<br />
Get<br />
Return newPropertyValue<br />
End Get<br />
Set(ByVal value As String)<br />
newPropertyValue = value<br />
End Set<br />
End Property<br />
<br />
<br />
Private Shared newPropertyValue2 As String<br />
Public Shared Property ClientTypeDesc() As String<br />
Get<br />
Return newPropertyValue2<br />
End Get<br />
Set(ByVal value As String)<br />
newPropertyValue2 = value<br />
End Set<br />
End Property<br />
<br />
Private Shared newPropertyValue3 As String<br />
Public Shared Property Coach() As String<br />
Get<br />
Return newPropertyValue3<br />
End Get<br />
Set(ByVal value As String)<br />
newPropertyValue3 = value<br />
End Set<br />
End Property<br />
<br />
<br />
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires when the application is started<br />
End Sub<br />
<br />
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires when the session is started<br />
End Sub<br />
<br />
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires at the beginning of each request<br />
End Sub<br />
<br />
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires upon attempting to authenticate the use<br />
End Sub<br />
<br />
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires when an error occurs<br />
End Sub<br />
<br />
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires when the session ends<br />
End Sub<br />
<br />
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)<br />
' Fires when the application ends<br />
End Sub<br />
<br />
End Class<br />
End Namespace<br />
<br />
<br />
Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="AdamItiel._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
QQQQQQQQQQQQQQQQQ
</div>
</form>
</body>
</html>
Default.aspx.VB
Namespace AdamItiel<br />
<br />
Public Partial Class _Default<br />
Inherits System.Web.UI.Page<br />
<br />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
<br />
End Sub<br />
<br />
End Class<br />
<br />
End Namespace<br />
<br />
Why do I get "Could not load type 'AdamItiel.GlobalApp'"?
|
|
|
|
|
Hi all,
In my website I have made program that if any error will come then an email comes to me.
I want to also know IP address,browsertype etc.. of that machine in the email.
Thanks to all..
|
|
|
|
|
code is below
Request.ServerVariables["REMOTE_ADDR"]
|
|
|
|
|
Thanks Dear,
But how can we get browser informatio ?
|
|
|
|
|
Look at this [^]one.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
you can get the information by Request.Browser.*.
For example
Request.Browser.Browser
you can get the user browser
|
|
|
|
|
private string GetClientIP()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:54am.
|
|
|
|
|
hi,
i am developing a web application where i am using asp:menu control to display menus.
ie version is ie7.
when there is less amount of data on a page the menu renders faster. Now for certain pages where i am using asp:Listbox control, when there are many items in the listbox control, the menu items are displayed slow. it takes some seconds to display the child menu items onhover. when there are lesser items in listbox the menu control render fast. This happens in ie7,but in ie6 that is not an issue. the menu displays faster in ie6 even when there is large amount of data in listbox
Sandeep Kumbhar
|
|
|
|
|
Hi,
I need to develop a .Net application that will store documents and enable users to read or write. While, Read access is available for all users, updates are allowed for only the user who has checked it out. This is similar to a version control application. I also have to store all the versions of the file. Please let me know the architectural/development details and efforts in terms of technology for such an application. Please point me to any resources/samples available. Any suggestions are appreciated.
Thanks.
|
|
|
|
|
This site is for specific questions--like you have a compile error, or getting unexpected results. This site is NOT for over-generic questions and how to teach you to use Google.
|
|
|
|
|
Hey I wanted to pose a couple of newbie questions. Sorry in advanced if they have already been asked in this forum, and thanks in advanced for those who volunteer or otherwise answer these types of questions. I know how the answer people can sometimes feel like their answers and efforts aren't appreciated by dummies, and can get jaded as a result.
Anyway, here are my questions:
1. I have a design or achitecture question. I want users to upload files to a shared mapped file drive, call it the "z:" drive where they can upload images or videos. I already have the code that will upload the images and such. But now I want serve those images or videos without physically moving/copying them to my server directory...I can't figure out how to do that as the absolute or relative path. Can anyone help me by providing a download url that has sample code that can do this? or point me in the right direction with some tutorial urls of what I'm looking for?
2. Last question (do I need to post this in a separate post? - that's not the question ). I would like have one .aspx affect a different .aspx page for seo reasons. Is there any way to do it programmatically? So I don't have to keep changing the page and then republishing to the web server? If so, any tutorials with sample code to do so?
Thanks!
|
|
|
|
|
1) You should be able to access your uploaded images (etc), by referencing them like "\\myimageserver\images\Photo1.jpg". You would just need to setup the necessary file sharing security for the IIS process to be able to read the file share and NTFS permissions. If anyone knows differently, please correct me ... I'm just thinking out loud.
2) So are you telling us that you have a page1.aspx actually modifying the contents of page2.aspx ? Wow, I've never done that ... I guess it's possible. Can you describe the actual situation with a bit more detail ? Maybe I could get a better understanding.
Always good to ask questions, how else are you going to learn ? I ask plenty of them.
|
|
|
|
|
clarification for #2: yes that's exactly what I want to do. I don't think it's possible though, just not sure.
on point #1, I don't think that works as I have tried that already, but if you get it to work, I'd love to see some code examples.
Thanks!
|
|
|
|
|
1) As long as the proper permissions have been applied to the folder I don't see why it shouldn't work
2) You could use some inline script within the head element
<head runat="server">
<%= InsertMeta() %>
</head>
protected string InsertMeta()
{
return @"<meta name='Test' content='Some value' />";
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi All.
How to get mac address of a client system in asp.net??
I need to identify client system uniquely other than using IP address.
If there is any other way for achieving the same please suggest...
Thanks and Regards
Mithun Narayanan.
|
|
|
|
|
And it involved this very issue. And a Senior MS Consultant (I hate to admit) showed me the path towards righteousness. Basically, your MAC address gets replaced with each frame along each router or some such non-sense. Meaning that outside your local network the MAC is meaningless. Much worse, some TCP/IP stacks do not even provide it through the API so you would need to really write some code to get it.
http://tools.ietf.org/html/rfc1122[^]
http://en.wikipedia.org/wiki/Ethernet[^]
|
|
|
|