Click here to Skip to main content
15,882,830 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Getting the Addons installed on the Browser!!! Pin
Minimech4-Mar-10 21:57
Minimech4-Mar-10 21:57 
Questionhow to print Landscape report using ASP.Net Pin
alisolution4-Mar-10 0:45
alisolution4-Mar-10 0:45 
AnswerRe: how to print Landscape report using ASP.Net Pin
Gaurav K Singh7-Mar-10 19:18
Gaurav K Singh7-Mar-10 19:18 
QuestionVisitor's Feedback Pin
awedaonline3-Mar-10 23:25
awedaonline3-Mar-10 23:25 
AnswerRe: Visitor's Feedback Pin
R. Giskard Reventlov3-Mar-10 23:37
R. Giskard Reventlov3-Mar-10 23:37 
GeneralRe: Visitor's Feedback Pin
tunsten4-Mar-10 2:26
tunsten4-Mar-10 2:26 
QuestionHow to convert a dataset to Excelsheet ? Pin
Subin Mavunkal3-Mar-10 22:54
Subin Mavunkal3-Mar-10 22:54 
AnswerRe: How to convert a dataset to Excelsheet ? Pin
April Fans3-Mar-10 23:25
April Fans3-Mar-10 23:25 
You can refer to the following code:
public int ExportToExcel(DataTable schemaTable, string tableName, string filePath, DataTable source)
{
string connString = "Provider = Microsoft.Jet.OLEDB.4.0 ;Persist Security Info=False; Data Source = " + filePath + ";Extended Properties=Excel 8.0;";//'HDR=Yes;IMEX=1";

if(System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
}

string create = "Create Table [";
create += tableName;
create += "] (";

string sourceColumn = "(";

foreach(DataRow dr in schemaTable.Rows)
{
string columnName = dr["ColumnName"].ToString();
//create string
create += "[";
create += columnName;
create += "]";

sourceColumn += "[" + columnName + "],";

string type = dr["DataType"].ToString();
switch(type)
{
case "System.Int32":
case "System.Int16":
case "System.Int64":
case "System.UInt32":
case "System.UInt16":
case "System.UInt64":
create += " INTEGER NULL,";
break;
case "System.Decimal":
case "System.Double":
case "System.Single":
create += " numeric NULL,";
break;
case "System.DateTime":
create += " datetime NULL,";
break;
case "System.Boolean":
create += " BINARY NULL,";
break;
default:
create += " varchar(";
create += dr["ColumnSize"].ToString();
create += ") NULL,";
break;
}
}
create = create.Substring(0, create.Length - 1);
create += ")";

using(OleDbConnection conn = new OleDbConnection(connString))
{
conn.Open();
using(OleDbTransaction trans = conn.BeginTransaction())
{
try
{
OleDbHelper.ExecuteNonQuery(trans, create);//create table

string insertHead = "Insert Into [" + tableName + "]" + sourceColumn.Substring(0, sourceColumn.Length - 1) + ") Values";

int result = 0;
foreach(DataRow dr in source.Rows)
{
string valueStr = "(";
for(int j = 0; j < source.Columns.Count; j++)
{
if(source.Columns[j].DataType == typeof(System.String))
{
valueStr += "'" + dr[j].ToString().Replace("'", "’") + "',";
}
else if(source.Columns[j].DataType == typeof(System.DateTime))
{
string date = dr[j].ToString();
if(date == string.Empty)
{
valueStr += "null,";
}
else
{
valueStr += "'" + date + "',";
}
}
else
{
valueStr += dr[j].ToString() + ",";
}
}
string insert = insertHead + valueStr.Substring(0, valueStr.Length - 1) + ")";
result += OleDbHelper.ExecuteNonQuery(trans, insert);
}
trans.Commit();
return result;
}
catch
{
trans.Rollback();
throw;
}
}
}
}
April

Comm100 - Leading Live Chat Software Provider


modified 27-May-14 8:43am.

GeneralRe: How to convert a dataset to Excelsheet ? Pin
Subin Mavunkal4-Mar-10 0:48
Subin Mavunkal4-Mar-10 0:48 
QuestionPostback event not firing from checkbox inside Gridview Pin
Santhosh Sebastian Mattathil3-Mar-10 22:01
Santhosh Sebastian Mattathil3-Mar-10 22:01 
AnswerRe: Postback event not firing from checkbox inside Gridview Pin
m@dhu3-Mar-10 22:37
m@dhu3-Mar-10 22:37 
QuestionHow to add a custom made menu item to the Master Page? Please reply Pin
robin_w3-Mar-10 21:28
robin_w3-Mar-10 21:28 
QuestionError Pin
4anusha43-Mar-10 21:03
4anusha43-Mar-10 21:03 
AnswerRe: Error Pin
Dinesh Mani3-Mar-10 21:32
Dinesh Mani3-Mar-10 21:32 
GeneralRe: Error Pin
4anusha43-Mar-10 22:51
4anusha43-Mar-10 22:51 
GeneralRe: Error Pin
Dinesh Mani3-Mar-10 23:01
Dinesh Mani3-Mar-10 23:01 
GeneralRe: Error Pin
4anusha43-Mar-10 23:05
4anusha43-Mar-10 23:05 
QuestionCreate and senda email in .net 3.5 Pin
kpuneeth73-Mar-10 19:50
kpuneeth73-Mar-10 19:50 
AnswerRe: Create and senda email in .net 3.5 Pin
Brij3-Mar-10 20:10
mentorBrij3-Mar-10 20:10 
GeneralRe: Create and senda email in .net 3.5 Pin
kpuneeth73-Mar-10 20:25
kpuneeth73-Mar-10 20:25 
GeneralRe: Create and senda email in .net 3.5 Pin
Brij3-Mar-10 21:01
mentorBrij3-Mar-10 21:01 
AnswerRe: Create and senda email in .net 3.5 Pin
Not Active4-Mar-10 0:19
mentorNot Active4-Mar-10 0:19 
Answer[Cross Post] Re: Create and senda email in .net 3.5 Pin
Scott Dorman4-Mar-10 4:36
professionalScott Dorman4-Mar-10 4:36 
QuestionReading excel data into datatable Pin
snehasish3-Mar-10 19:45
snehasish3-Mar-10 19:45 
AnswerRe: Reading excel data into datatable Pin
Dinesh Mani3-Mar-10 21:42
Dinesh Mani3-Mar-10 21:42 

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.