Web Forms :: How To Read Particular Data From Excel Using Placeholder
Jun 18, 2012
I have an excel sheet in that all the data is added what i want is my webpage should be change as soon as i modify my excel Sheet and automatically a new aspx page generate if any data will add in excel sheet.
I need to create the CMS of my webpage which will be totally dynamic and record must be store and read from excel only.
I am using list view to display the the data but i am getting an error like An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server.Even i have specified the itemplaceholder id but no use still same error.
I am reading data from Excel file using oledbdataadapter and binding to gridview.Every thing working fine.but if the cell is having some text along with bar sysmol ( | ) [Ex : 12345 | 789123] that cell data is not reading from excel file.All fileds in excel sheet is text format only.Some times it's reading correctly & some times it not reading(empty).Is there any problem with bar symbol ( | )
string strFileName = FileUpload1.PostedFile.FileName; string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFileName + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(connectionString); objConn.Open(); String strConString = "SELECT * FROM [Product Classification 5$]"; //where date = CDate('" + DateTime.Today.ToShortDateString() + "')"; OleDbCommand objCmdSelect = new OleDbCommand(strConString, objConn); // Create new OleDbDataAdapter that is used to build a DataSet // based on the preceding SQL SELECT statement. OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); // Pass the Select command to the adapter. objAdapter1.SelectCommand = objCmdSelect; // Create new DataSet to hold information from the worksheet. DataSet objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1, "ExcelData");
but in it doesnt read the Description data of 20 & 30 because somebody said if the first cell value is string type then all the column should be string but in mycase its coming as mixed(alpha & numeric), so that it cant read the data, i tried to convert the column as Text then also the same problem continues,
I want to read Excel document using C#. I am not a professional so I need examples to learn the technique. If anyone provides useful link, information, api library.
I have 3 excel files having uniqe column Name JobNo. i want to develop a web page containing serach option based on Jobno.
User just type the jobno and press on search button corresponding record should be display on grid view.record may present any of the excel sheet.how can i acheive this.
ID Name Contact No Address 1 ABC XXXXXXX ABCNM2 XYZ xxxxxxx ASDFG
Now my requirement is read data from this excel sheet and den encrypt Contact No field for each row and den save data in database, how should it will be done I have to use some ready made available encryption algo for that.
My web page contains a file upload control that is used to select excel file. What my code does; is to read the content of that file and store its content to DB. Right now, I save this file to server and read its content using OLEDB.I want to know is there any way i can read the content without saving it on the server?
I have an Excel file called Products.xls .I have Columns A and B, with the titles NAME and QUANTITY.The name of the sheet is SHEET1.The file has about 40 lines.How do i show these data on a Gridview or Listview ?
Import Data from Excel to Gridview ([URL]) By following the code as mentioned in the post i am able to get excel sheet values and c display them in gridview.
But I want to read Images from Excel sheet and display them in Gridview and also insert them in sql server..
I have a file pdf, in file pdf of me has a table with many columns. How to Fill data from file pdf to columns of file Excel?I want fill data from file table of file pdf to file excel following format of file pdf.
I am having two text boxes in a form (ASP) when I entered the value in text box it is passed to excel sheet .I am doing some calculation in excel-2003 for example(A+B=C).I am able to pass text box values to excel but I am unable to retrieve the calculated value from excel to the form. In Excel sheet the result is getting updated.
how to maintain state of placeholder. i have a placeholder in which i add many image controls dynamically but when my page get refresh all controls from placeholder gets removed from it. the enableViewstate of placeholder is set to true.
I have developed an application where I need to create a page to read data from Excel File and then update it to the database. The code that I wrote works only when the application runs from my machine. When I deployed the application to the server it gave an error- 'C:PRFileIimport_File.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. here is mu code -
protected void InsertData(object sender, EventArgs e) { OleDbConnection oConn = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\PuertoRicoFile\Puertorico_Iimport_File.xls ; Extended Properties=Excel 8.0 "); OleDbCommand oCmd = new OleDbCommand("select * from [Puertorico_Data$]", oConn); oConn.Open(); //Here [Puertorico_Data$] is the name of the sheet in the Excel file where the data is present OleDbDataReader oleDbReader = oCmd.ExecuteReader(); string AgentIP = ""; string TagName = ""; string Status = ""; string Severity = ""; int EventCount = 0; string EarliestEvent = ""; string LatestEvent = ""; while (oleDbReader.Read()) { AgentIP = (string)oleDbReader[0]; // valid(oleDbReader, 0);//Here we are calling the valid method TagName = (string)oleDbReader[1]; //valid(oleDbReader, 1); Status = (string)oleDbReader[2]; //valid(oleDbReader, 2); Severity = (string)oleDbReader[3]; //valid(oleDbReader, 3); EventCount = Convert.ToInt32(oleDbReader[4]); //oleDbReader[0]; //valid(oleDbReader, 4); EarliestEvent = (string)oleDbReader[8]; //validate(oleDbReader, 8); EarliestEvent = EarliestEvent.Substring(0, 19); LatestEvent = (string)oleDbReader[9]; //validate(oleDbReader, 9); LatestEvent = EarliestEvent.Substring(0, 19); InsertDataIntoSql(AgentIP, TagName, Status, Severity, EventCount, EarliestEvent, LatestEvent); } SqlConnection mySQLconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["IssNetworkReportingSystemConnString"].ConnectionString); mySQLconnection.Open(); SqlCommand cmdSql = new SqlCommand("AddMonth_Event_TotalInfo_for_Puertorico", mySQLconnection); cmdSql.CommandType = CommandType.StoredProcedure; dbReader = cmdSql.ExecuteReader(); dbReader.Close(); cmdSql = new SqlCommand("AddQtr_Event_TotalInfo_for_Puertorico", mySQLconnection); cmdSql.CommandType = CommandType.StoredProcedure; dbReader = cmdSql.ExecuteReader(); dbReader.Close(); oConn.Close(); lblMsg.Text = "Data Imported Sucessfully"; lblMsg.ForeColor = System.Drawing.Color.Green; } public void InsertDataIntoSql(string agentIP, string tagName, string Stat,string severity,int eventCount, string eEvent, string lEvent) {//inserting data into the Sql Server SqlConnection mySQLconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["IssNetworkReportingSystemConnString"].ConnectionString); mySQLconnection.Open(); SqlCommand sqlSelect = new SqlCommand("SELECT SeverityID from Severity where SeverityDesc=@SeverityDesc",mySQLconnection); sqlSelect.CommandType = CommandType.Text; sqlSelect.Parameters.Add("@SeverityDesc", SqlDbType.NVarChar).Value = severity; dbReader = sqlSelect.ExecuteReader(); int severityId = Convert.ToInt32(dbReader.Read()); dbReader.Close(); SqlCommand sqlInsert = new SqlCommand("Insert into IdsData_Puertorico(AgentIP,TagName,Status,SeverityID,EventCount,EarliestEvent,LatestEvent)" + " values (@AgentIP,@TagName,@Status,@SeverityID,@EventCount,@EarliestEvent,@LatestEvent )" ,mySQLconnection); sqlInsert.CommandTimeout = 0; //timeout unlimited sqlInsert.CommandType = CommandType.Text; sqlInsert.Parameters.Add("@AgentIP", SqlDbType.NVarChar).Value = agentIP; sqlInsert.Parameters.Add("@TagName", SqlDbType.NVarChar).Value = tagName; sqlInsert.Parameters.Add("@Status", SqlDbType.NVarChar).Value = Stat; sqlInsert.Parameters.Add("@SeverityID", SqlDbType.Int).Value = Convert.ToInt32(severityId); sqlInsert.Parameters.Add("@EventCount", SqlDbType.Int).Value = Convert.ToInt32(eventCount); sqlInsert.Parameters.Add("@EarliestEvent", SqlDbType.DateTime).Value = DateTime.Parse(eEvent); sqlInsert.Parameters.Add("@LatestEvent", SqlDbType.DateTime).Value = DateTime.Parse(lEvent); sqlInsert.CommandType = CommandType.Text; sqlInsert.ExecuteNonQuery(); mySQLconnection.Close(); }
"The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"."
I am running SQL 2005 on Windows SBS 2003 server.
Also on solution 3 you running the below sql query
Do i need to run it on the master database or on my database?
USE [master] GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 GO