VS 2010 - Reading Excel Data Into Dataset Loses Data
Apr 22, 2014
I have a client that provides a .xls file on their site that we have no control over that we download the file and then read it to update inventory. The first column is the SKU and in cell A2 it has the value 1028. This outputs fine but when I get to A8 the value is '1051-LV' and in my output it is blank. I am thinking in my dataset it reads A2 value and that becomes the type for the remainder of the rows. But what if that is wrong? How do I fix so it doesn't set the datetype to say int when it could be a string type?
Below is my code and works but the output of certain rows sku values are blank and are not like that in the excel file.
Code:
Protected Sub btnGetExcelFile_Click(sender As Object, e As System.EventArgs) Handles btnGetExcelFile.Click
litOutput.Text = ""
Dim ws As New WebPost
ws.URL = "http://www.domain.com/dropship/feed.xls"
'downloads excel file based on url
Dim bExcel() As Byte = ws.RequestBinaryData("", True)
[Code] ....
View 2 Replies
Similar Messages:
Apr 4, 2012
It cant be more simple. However I have tried a lot of examples and none of them have been working.
I have a very simple Excel file. I want to post these data in a gridview, Column A, B and C all placed in the Sheet1 and the file name is Book1.xls.
View 2 Replies
Jan 18, 2010
What I am thinking is this? Is it possible for me to upload the data from an excel file to dataset of my application first, so that the user can view the data in a gridview to review it first, before the user strike the save button, to save it in the database. So, that in case there is a problem, the gridview will high light all the data with an error. So the user can easily pull out the excel and correct the data before saving it in the database.
View 4 Replies
Mar 1, 2011
I have a scenario where I have to read an excel file to dump records in a mysql database. The code generates an exception Sheet1 not found. I have pasted the code below. Please let me know the solution to the exception. I have given the correct read/write/modify settings to my excel file.
if (fileUpload1.PostedFile.FileName.EndsWith(".xls") || fileUpload1.PostedFile.FileName.EndsWith(".XLS"))
{
string fileName = Server.MapPath(fileUpload1.PostedFile.FileName);
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=Excel 8.0";
// Create the connection object
OleDbConnection oledbConn = new OleDbConnection(connString);
try
{
// Open connection
oledbConn.Open();
// Create OleDbCommand object and select data from worksheet Sheet1
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]" , oledbConn);
// Create new OleDbDataAdapter
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
// Create a DataSet which will hold the data extracted from the worksheet.
DataSet ds = new DataSet();
// Fill the DataSet from the data extracted from the worksheet.
oleda.Fill(ds, "RestaurantExcelData");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("Data: " + ds.Tables[0].Rows[i].ItemArray[0].ToString() + "");
}
}
catch(Exception e1)
{
}
finally
{
// Close connection
oledbConn.Close();
}
}
else
{
Response.Write("File Not Excel (xls||XLS)");
}
View 2 Replies
May 18, 2010
I am trying to read data from excel file in asp.net. I have added the connection string to webConfig file:
<add name="xls" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=HPM_DB.xls;Extended Properties=Excel 8.0"/>
But it shows me an errormessage when I run this query:
string query = "Select * from [IO_Definition$]";
IO_Definition is the name of the spreadsheet in my excel file. I also added the excel file to the App_Data folder of the website.
The error is:
The Microsoft Jet database engine could not find the object 'IO_Definition$'. Make sure the object exists and that you spell its name and the path name correctly.
The thing is, when I write the absolute path of the excel file in the connectionString it does work. Is there anyway I can make it work without writing the absolute path?
View 1 Replies
Feb 26, 2011
I want to read data from an excel sheet which is in non-standard format. I have tried many things but could not find a solution,
View 1 Replies
Sep 23, 2010
Using C# to develop an application.I need to upload data ( which is in excel) to a sql table.
[Code]....
View 1 Replies
Aug 3, 2010
I am attempting to read data from an uploaded spreadsheet using ACE.OLEDB. The code, which is running fine on dev and test machines for XL2003/2007 reports "Exernal table is not in the expected format" error on connecting on the production server for XL2007 only.The code is
Dim connectionString As String = "provider=Microsoft.Ace.OLEDB.12.0;" _ & "Data Source='" & ImportData.FullName & "';Extended Properties=Excel 12.0;" LogWebActivity.LogThis("Entering POPSUKD, ConStr=" & connectionString, LogWebActivity.LogDetailLevel.DetailAndData) Dim con As New System.Data.OleDb.OleDbConnection(connectionString) LogWebActivity.LogThis("Dimmed con", LogWebActivity.LogDetailLevel.Debugging) Try Dim cmdSelect As New System.Data.OleDb.OleDbCommand("SELECT * FROM [" & WorksheetName & "$]", con) Dim adapter As New System.Data.OleDb.OleDbDataAdapter(cmdSelect) Dim dS As New Data.DataSet LogWebActivity.LogThis(cmdSelect.CommandText, LogWebActivity.LogDetailLevel.Debugging) con.Open() LogWebActivity.LogThis("Opened Connection", LogWebActivity.LogDetailLevel.Debugging) adapter.Fill(dS, WorksheetName) LogWebActivity.LogThis("Filled DataAdapter", LogWebActivity.LogDetailLevel.Debugging) _SKUS = dS.Tables(WorksheetName) LogWebActivity.LogThis("Set SKUS", LogWebActivity.LogDetailLevel.Debugging)
View 1 Replies
Jan 5, 2013
I have made an application to read data from an excel file and save to database "Access". It's working perfect except one thing that..There are 4 columns in excel file as :
Shop no
owner address
alternate member address
permanent member address
For all fields i have kept same datatype in database as "text". As in above image In Column A "shop no" in some rows there are same shop no with A,B,C classes. Now when I am uploading this excel file it saving all data, but in Column A cells which having only numbers would be saving to database eg: 185, 187, 188. And the cells which has both number and class eg: 185 A, 185 B would be reading as null values.
View 1 Replies
Mar 2, 2011
i am use this code for read excel file:
[Code]....
how to read special cells in excel and I save to DB.
for example: B4 and C4 is merged with named B4.how to read Data of this cell.
View 4 Replies
Jun 9, 2010
I am working on a comparison tool that will take an excel file and a .csv file and find differences. The user is going to be selecting the two files from their local machine via the .NET FileUpload control. The issue I am running into is that I don't want to write the files to the server first so using something like below won't work for me, as "Book1.xls" or even " + FilePath + " in place of it won't work. I need to be able to read the posted files into memory, then create maybe datatables of them, then do my comparison code.
[Code]....
I have some code that reads the PostedFile into a stream but I don't know how I can use that stream with the above code. Then I have some that can read the .csv file, but if it is an excel file, I get a bunch of Excel garbage along with the data...
[Code]....
How can I read into clean data from a FileUpload control of an Excel document?
View 5 Replies
May 24, 2010
I am using reading data from excel file and inserting into sql server using following article, it seems to be working correctly except when I do page refresh normally, it again execute the the btnUpload_click. I want that once the record imported and if user refresh the page again it should ask for enter file name again. let me know how do I resolve this? [URL]
View 8 Replies
Apr 14, 2010
I am usig ADO.NET to fetch a Dataset and then exporting the data to excel using Response.Write with response type set as excel. However when I run the application I am getting the following error in the browser."Cannot view XML input using XSL style sheet. Please correct the error and then click theRefresh button, or try again later."Anybody has any idea on why do we get this error and any pointers to resolve this error? By the way the same code does works on another machine, it's just not working on few machines.
View 1 Replies
Feb 2, 2010
I got data retrieved from Sql DB in a 3 different dataset. I need to get all data from
View 7 Replies
Dec 18, 2010
Had a datareader question.
[Code].......
Return myDataReader I have a function which is retuning a datareader to various sections of my website which is then being bound to dropdown lists, gridviews, etc. Normally the last line in a function when is the data reader and connection getting closed? Is it best practive to return a data reader or a dataset/datatable (or something even better than these two)?
View 8 Replies
Feb 9, 2010
In a page im having multiple data grids with some data tables.How can i export all these to excel sheet without any change in the alignment.
View 6 Replies
Jun 28, 2010
I want to Export dataset data to excel ,when i click gridview linkbutton.
My Scenior is : Actually i am Passing a parameter from griview linkbutton.Depending on the parameter value .I want to export dataset data to excel.
View 7 Replies
Oct 19, 2010
I can directly use to read and display Excel or CSV files using asp web control(GridView, sqldatasource etc). I do NOT want to upload the file first to an sql database before reading them, I just want to read the files directly. I am using asp.net 2.0 and c#.
View 3 Replies
Mar 22, 2011
I need to read an Excel work book with 2 sheet which have more than 60,000 records. The application is an ASP.Net application so the performance matters.
Which approach should I take? Sohuld I do it using Microsoft.Office.Interop.Excel or should I do it using OLEDB in ADO.Net?
View 3 Replies
Nov 14, 2010
how to parse excel files data in ASP.NET WebForms using C# or ASP.NET MVC using C#?
View 8 Replies
Dec 21, 2010
I have a detailsview, template as follows:
[Code]....
Codebehind: creating dataset, getting data from sql with adaptor and filling into dataset object, then setting detailsview's datasource.
I add 2 button to above template to able to edit data at asp page, and added event handlers:buttons:
[Code]....
My question is, what to do inside the detailsview update event function to able to edit and update data. My method can be wrong too.
View 7 Replies
Feb 11, 2010
I create a gridview dynamically to fit the contents of a datatable...This form will have other dataatbles thrown at it but for the moment I am only working on one to work out the details of the process.I will post all my code below...the problem is this. The code successfully geenrates the gridview the way I want however...whenever I select a row all the cells including the header cells dissapears
[code]...
View 3 Replies
Jun 28, 2010
i have retrieved data from the database and stored in dataset.i have to add an additonal row to it,update the data in data set and delete data from the data set..
View 6 Replies
Sep 1, 2010
i have try to export data to excel using gridview.
I have export it successfully but some data is missing which is due to the column format in the exported excel file is not TEXT .
[Code]....
I need to set the exported excel file column format to TEXT but find no solution on this.
View 2 Replies
Nov 22, 2015
In the above mentioned article at "[URL]" instead of selecting the existed table in dbserver is it possible to create a dynamic database table based upon the structure of the excel file to be loaded??
View 1 Replies