Databases :: Insert Data To Excel Using OLEDB?
Aug 18, 2010I am trying to insert data to Excel Document using OLEDB as follows:-
sql = "Insert into [MyFirstSheet$] (" + Title1 + "," +Title2 + "," + Title3 + ")
I am trying to insert data to Excel Document using OLEDB as follows:-
sql = "Insert into [MyFirstSheet$] (" + Title1 + "," +Title2 + "," + Title3 + ")
Using OleDB, I want to access the hyperlink part of the cell but I'm stumped because I can't figure this out. Here is what I have thus far.
[Code]....
The hyperlink is in the Number field. So using OleDB, can I do this?
I have a excel sheet and I want to make the 2nd row my header column and read the data from the 3rd row, considering 2nd row is the Column name.
View 1 Repliesi have made a connection and retrieve the data from the excel sheet. however when i run a query to update or insert some data into excel sheet it will generate an error "Cannot expand named range"
View 2 Repliesi got the following error while i am trying to get my web application to run on windows server 2003. I've installed 2007 data access components on windows server 2003 but the web application does not seem to work. The codes that i use is as follows:
[code]....
I've read a lot of forum posts and almost all of them mentioned ab out the connectionstring being wrong. However, when i ran the codes on my local machine, there were no errors. The error only show when i was running on windows server 2003.
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?
I need to set connection timeout in oledb connection string like
stringA= "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=sa;PWD=password;Initial Catalog=DB;Data Source=127.0.0.1;Connect
Timeout=30" [code]....
Is there a way to import an amount of data from an excel sheet using the sheet rowindex, something like: SELECT * FROM [PLAN1$] WHERE ROWINDEX BETWEEN 1 AND 1000?
View 1 RepliesCan you tranfer the data from Excel to another Excel using Asp.net 3.5 without saving it to database.
View 1 RepliesI got an error about OleDB. I just want my excel file import to Gridview. Here is my code.
string connstr =
"Provider=Microsoft.Jet.Oledb.4.0;Data
Source=C:a.xls;Extended
Properties=Excel 8.0;HDR=YES;IMEX=1";
OleDbConnection conn = new OleDbConnection(connstr);
string strSQL = "Select * from [Sheet1$]";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
When i build project there is no error but when i run this project i got an error like this:
System.ArgumentException:Format of the
initialization string does not conform
to specification starting at index 47.
Line 21: string connstr =
"Provider=Microsoft.Jet.Oledb.4.0;Data
Source=C:a.xls;Extended
Properties=Excel 8.0;HDR=YES;IMEX=1";
Line 22: Line 23:
OleDbConnection conn = new
OleDbConnection(connstr);
How can i fix this?
I have a form wilh couple of Drop downs and text boxes and a Data Grid View which displays data from Access Table. When I hit add button on the form, I can see the data being added to the Grid View. But when I close the form and open the Access Database File (.mdb), the respective table is empty. The Access Table is not being updated. Second time if I open the form, the Grid View is also empty.I am pasting my code here.
Public Class Home
Shared OleDbConnection As System.Data.OleDb.OleDbConnection
Shared ExpensesDataAdapter As System.Data.OleDb.OleDbDataAdapter [code]....
I am Importing an excel file using oledb connection in asp.net.
but it is not working on server.
now i want to read excel file without interop.
How can i do it.
i am using oledb to connect with oracle from asp.net. i am inserting image into my database.i could insert large and samll image into database. but i couldn't update large image with small image. ie if i insert small image(50kb)and if i want to update small image with large image(200kb) it is not updating.it updates with null value. i don't know why.
View 6 Repliesi want to export multiple tables in a dataset to excel workbook with each tables as sheets without using COM Interop or Excel Object.
View 2 RepliesI want to fetch data from a excel sheet. Can anyone tell me how we can acheive this I also want to edit that data and then again place it on excel sheet.
View 6 Repliesi had 2 columns in the excel file one is SNo and another Description
looks like below
Sno Description
1 1/2 Feet
2 1/5 Feet
3 20
4 30
i read the data from this file using below code
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,
How do I do that using c#?
I have a texbox and two buttons.
I need the ability for a user to browse to an Excel sheet stored on his local machine and save the contents into a database table.
View 1 Repliesi want to find data from excel sheet using c# my excel sheet like this
Sr. No.
Store Code
Store Name
City
State
1
3062
C.G.Road.
Ahmedabad
Gujarat
2
3103
Iscon Mega Mall 2
Rajkot
Gujarat
3
3113
New Gandhi Nagar
Ghaziabad
Delhi
4........................
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)");
}
I want to create a application which can be able to read data from excel sheet and process and print it.
View 3 RepliesI 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.
Using C# to develop an application.I need to upload data ( which is in excel) to a sql table.
[Code]....
I have write the code for deleting the data in excel sheet. but we have got the error" Deleting data in a linked table is not supported by this ISAM." below I paste some code snippest.
string strDelete = "Delete from [" + strSheetName + "$]";
cmdExcel.Connection = con;
cmdExcel.CommandType = CommandType.Text;
cmdExcel.CommandText = strDelete;
cmdExcel.ExecuteNonQuery();
how can i export mysql data to Excel?
View 3 Replies