Click here to Skip to main content
15,889,216 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Pssing value using Post method??? Pin
Guffa17-Nov-08 22:13
Guffa17-Nov-08 22:13 
QuestionGlobalization Problem Pin
Prasanna Kumar Pete17-Nov-08 18:06
Prasanna Kumar Pete17-Nov-08 18:06 
AnswerRe: Globalization Problem Pin
Christian Graus17-Nov-08 21:11
protectorChristian Graus17-Nov-08 21:11 
QuestionError - when uploading excel file to server Pin
Satish - Developer17-Nov-08 17:37
Satish - Developer17-Nov-08 17:37 
AnswerRe: Error - when uploading excel file to server Pin
l.laxmikant17-Nov-08 17:45
l.laxmikant17-Nov-08 17:45 
GeneralRe: Error - when uploading excel file to server Pin
Satish - Developer17-Nov-08 17:59
Satish - Developer17-Nov-08 17:59 
GeneralRe: Error - when uploading excel file to server Pin
VijayVishwakarma17-Nov-08 18:24
VijayVishwakarma17-Nov-08 18:24 
GeneralRe: Error - when uploading excel file to server Pin
Satish - Developer17-Nov-08 20:33
Satish - Developer17-Nov-08 20:33 
My code is as follows. I am Getting error here... as
"Excel Excep:The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data."

public DataTable ReadingDatafromExcel()
    {
        DataTable dt = new DataTable();
        try
        {
            //Reading Data from Excel file to Data Table
            string FilePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
            string _filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string _attachpath = FileUpload1.PostedFile.FileName;
            string _fileexten = Path.GetExtension(FileUpload1.PostedFile.FileName);

            string strConn = "";

            if (_fileexten == ".xls")
            {
                strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                          "Data Source=" + _attachpath + ";" +
                          "Extended Properties=Excel 8.0;";
            }
            else if (_fileexten == ".xlsx")
            {
                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                          "Data Source=" + _attachpath + ";" +
                          "Extended Properties=Excel 12.0;";
            }

            OleDbConnection oledbconn = new OleDbConnection(strConn);
            oledbconn.Close();
            oledbconn.Open();
            //You must use the $ after the object you reference in the spreadsheet
            OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", oledbconn);

            DataSet myDataSet = new DataSet();
            

            myCommand.Fill(myDataSet, "ExcelInfo");
            dt = myDataSet.Tables[0];
            oledbconn.Close();
            myCommand.Dispose();

            //Adding Columns to Data table

            DataColumn dcGender = new DataColumn("Gender", System.Type.GetType("System.String"));
            dt.Columns.Add(dcGender);

            DataColumn dcCulture = new DataColumn("Culture", System.Type.GetType("System.String"));
            dt.Columns.Add(dcCulture);
            
        }
        catch (Exception dataex)
        {
            Response.Write("Excel Excep:" + dataex.Message.ToString());
        }
        return dt;
    }


G. Satish

Questionwindows control on a web page Pin
Tabb Smith17-Nov-08 16:50
Tabb Smith17-Nov-08 16:50 
AnswerRe: windows control on a web page Pin
Christian Graus17-Nov-08 21:12
protectorChristian Graus17-Nov-08 21:12 
Questionrookie question about a simple code Pin
Yifei Jia17-Nov-08 16:03
Yifei Jia17-Nov-08 16:03 
AnswerRe: rookie question about a simple code Pin
Abhijit Jana17-Nov-08 17:45
professionalAbhijit Jana17-Nov-08 17:45 
AnswerRe: rookie question about a simple code Pin
Christian Graus17-Nov-08 21:13
protectorChristian Graus17-Nov-08 21:13 
QuestionNeed Help Pin
learningman17-Nov-08 12:46
learningman17-Nov-08 12:46 
AnswerRe: Need Help Pin
Christian Graus17-Nov-08 14:46
protectorChristian Graus17-Nov-08 14:46 
QuestionDataSet problem [modified] Pin
Phrone17-Nov-08 10:54
Phrone17-Nov-08 10:54 
AnswerRe: DataSet problem Pin
Christian Graus17-Nov-08 11:31
protectorChristian Graus17-Nov-08 11:31 
GeneralRe: DataSet problem Pin
Phrone17-Nov-08 11:46
Phrone17-Nov-08 11:46 
GeneralRe: DataSet problem Pin
Christian Graus17-Nov-08 14:47
protectorChristian Graus17-Nov-08 14:47 
Questionregister user control non declaratively Pin
hassanmohamed17-Nov-08 10:14
hassanmohamed17-Nov-08 10:14 
AnswerRe: register user control non declaratively Pin
Christian Graus17-Nov-08 11:33
protectorChristian Graus17-Nov-08 11:33 
Questionsave .csv with newline character Pin
ssircar197117-Nov-08 9:53
ssircar197117-Nov-08 9:53 
AnswerRe: save .csv with newline character Pin
NeverHeardOfMe17-Nov-08 11:08
NeverHeardOfMe17-Nov-08 11:08 
AnswerRe: save .csv with newline character Pin
Christian Graus17-Nov-08 11:34
protectorChristian Graus17-Nov-08 11:34 
QuestionAdding web reference problem because of autodetectcookiesupport Pin
AlexeiXX317-Nov-08 6:57
AlexeiXX317-Nov-08 6:57 

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.