Click here to Skip to main content
15,886,724 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Milliseconds from excel Pin
Richard Deeming16-May-22 21:35
mveRichard Deeming16-May-22 21:35 
GeneralRe: Milliseconds from excel Pin
kjell.ek16-May-22 23:15
kjell.ek16-May-22 23:15 
AnswerRe: Milliseconds from excel Pin
Raj Kumar7918-Oct-22 5:12
Raj Kumar7918-Oct-22 5:12 
QuestionASP.NET Gridview load data Pin
Herman<T>.Instance28-Apr-22 3:16
Herman<T>.Instance28-Apr-22 3:16 
AnswerRe: ASP.NET Gridview load data Pin
Richard Deeming28-Apr-22 4:40
mveRichard Deeming28-Apr-22 4:40 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance2-May-22 0:47
Herman<T>.Instance2-May-22 0:47 
GeneralRe: ASP.NET Gridview load data PinPopular
Dave Kreskowiak2-May-22 2:12
mveDave Kreskowiak2-May-22 2:12 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance2-May-22 3:23
Herman<T>.Instance2-May-22 3:23 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance3-May-22 4:46
Herman<T>.Instance3-May-22 4:46 
GeneralRe: ASP.NET Gridview load data Pin
Richard Deeming3-May-22 5:31
mveRichard Deeming3-May-22 5:31 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance3-May-22 5:38
Herman<T>.Instance3-May-22 5:38 
GeneralRe: ASP.NET Gridview load data Pin
Richard Deeming3-May-22 5:48
mveRichard Deeming3-May-22 5:48 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance3-May-22 7:12
Herman<T>.Instance3-May-22 7:12 
GeneralRe: ASP.NET Gridview load data Pin
Richard Deeming3-May-22 21:38
mveRichard Deeming3-May-22 21:38 
GeneralRe: ASP.NET Gridview load data Pin
Herman<T>.Instance3-May-22 22:03
Herman<T>.Instance3-May-22 22:03 
QuestionSend Email using Classic ASP Pin
Ram Teckchandani11-Apr-22 17:28
Ram Teckchandani11-Apr-22 17:28 
AnswerRe: Send Email using Classic ASP Pin
Richard MacCutchan11-Apr-22 22:00
mveRichard MacCutchan11-Apr-22 22:00 
QuestionMVC 5 Prevent Users From Going Back After Logging In or Out Using Identity Framework Pin
Steven Petersen3-Apr-22 9:11
Steven Petersen3-Apr-22 9:11 
AnswerRe: MVC 5 Prevent Users From Going Back After Logging In or Out Using Identity Framework Pin
Richard Deeming3-Apr-22 21:24
mveRichard Deeming3-Apr-22 21:24 
QuestionA question about CreatedAtAction() method Pin
Alex Dunlop23-Mar-22 21:44
Alex Dunlop23-Mar-22 21:44 
AnswerRe: A question about CreatedAtAction() method Pin
Richard MacCutchan23-Mar-22 21:50
mveRichard MacCutchan23-Mar-22 21:50 
QuestionA question about routing attribute Pin
Alex Dunlop23-Mar-22 21:41
Alex Dunlop23-Mar-22 21:41 
AnswerRe: A question about routing attribute Pin
Richard MacCutchan23-Mar-22 21:51
mveRichard MacCutchan23-Mar-22 21:51 
GeneralRe: A question about routing attribute Pin
Leeladhar Ladia25-Mar-22 3:46
Leeladhar Ladia25-Mar-22 3:46 
Questionexportar datos de sql server a archivo .csv con C# asp.net Pin
Member 1556240011-Mar-22 8:08
Member 1556240011-Mar-22 8:08 
Hello group, a question please. The data from my databases all come out in a single string per row in the .csv file, how can I print it in a cell per field in the .csv file? I attach images and code for more clarity with the problem. Thanks


<pre lang="C#">
public partial class CS : System.Web.UI.Page {
protected void ExportCSV(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["PRUEBASConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);

//Build the CSV file data as a Comma separated string.
string csv = string.Empty;

foreach (DataColumn column in dt.Columns)
{
//Add the Header row for CSV file.
csv += column.ColumnName + ',';
}

//Add new line.
csv += "\r\n";

foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
//Add the Data rows.
csv += row[column.ColumnName].ToString().Replace(",", ";") + ',';
}

//Add new line.
csv += "\r\n";
}

//Download the CSV file.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=SqlExport.csv");
Response.Charset = "";
Response.ContentType = "application/text";
Response.Output.Write(csv);
Response.Flush();
Response.End();
}
}
}
}
} }

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.