2 Replies - 6646 Views - Last Post: 24 February 2011 - 12:13 PM Rate Topic: -----

#1 krista80  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 22-February 11

Cannot Update. Database or object is read-only

Posted 23 February 2011 - 01:57 PM

The new error I am getting is this: "Cannot update. Database or object is read-only."

My code looks like this:
else if (fileType == ".xls")
                    {
                        string strConnXLS;

                        strConnXLS = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;" +
                            "Data Source={0};Extended Properties=Excel 8.0;", docCSV.PostedFile);

                        OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Template$A10:P51]", strConnXLS);

                        DataTable myDT = new DataTable();
                        myCommand.Fill(myDT);

                        for (int x = 0; x < myDT.Rows.Count; x++)
                        {
                            string rowString = "";
                            for (int y = 0; y < myDT.Columns.Count; y++)
                            {
                                rowString += "\"" + myDT.Rows[x][y].ToString() + "\",";
                            }
                            string[] tempArray = rowString.Split(Convert.ToChar(","));
                            ExcelLoadDataToDatabase(tempArray);
                        }
                        
                    }

I am trying to make the xls file into csv type lines, which are then saved to an array. But before that happens I am getting this error at the myCommand.Fill(myDT) line.

I am trying also to get this line:
strConnXLS = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;" +
                            "Data Source={0};Extended Properties=Excel 8.0;", docCSV.PostedFile);
to work with a FileUpload control.

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot Update. Database or object is read-only

#2 krista80  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 22-February 11

Re: Cannot Update. Database or object is read-only

Posted 24 February 2011 - 07:17 AM

Hi again. I have changed the code to this:
strConnXLS = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;" +
06	                            "Data Source={0};Extended Properties=Excel 8.0;Readonly=False;", docCSV.PostedFile);

and now I am given another error: "Could not find installable ISAM".
Any help?
Was This Post Helpful? 0
  • +
  • -

#3 krista80  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 22-February 11

Re: Cannot Update. Database or object is read-only

Posted 24 February 2011 - 12:13 PM

I have solved my problem. Thanks to all who helped. What I had to do is save the file to the server, then connect to it from there. Thank you to everyone who helped!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1