|
 |
aspx_beginners thread: Writing data into Excel
Message #1 by "Sergiy" <sergiy@x...> on Sun, 28 Jul 2002 18:33:31 +1200
|
|
I am writing some data into Excel spreadsheet. The code:
Dim strSource As String = Server.MapPath("ExcelData1.xls") + ";"
Dim m_sConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=" & strSource & _
"Extended Properties=""Excel 8.0;HDR=YES"""
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
Try
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conn1
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate)
values ('New', '111', '10/14/48')"
cmd.ExecuteNonQuery()
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate)
values ('New 2', 'Deloris 55', '7/19/98')"
cmd.ExecuteNonQuery()
. . .
The code runs perfectly at one computer (Windows 2000 OS), but when I
created the exactly the same application at another computer (with Windows
XP OS) it gives an error:
'System.Data.OleDb.OleDbException: Operation must use an updateable query.'
The line: cmd.ExecuteNonQuery() caused the error.
I believe that it caused by the security permissions,
because when I copied the Excel file into folder "c:\aa" and set is as
shared folder ,
etc, the application run without any problem. I only changed the source
path:
Dim strSource As String = "C:\aa\ExcelData1.xls;"
I tried: set permissions to write in IIS for this application, set ASPNet
account for this folder with all permissions, but all the same.
So which settings necessary to change to allow writing into the file?
Message #2 by "Sri Vidya" <svsvidya@i...> on Mon, 29 Jul 2002 10:10:30 +0530
|
|
Hi Sergiy,
I am not sure because I have not worked on windows XP yet. Shall try
to find out and get back to you on this one.
Cheers,
Vidya.
On Sun, 28 Jul 2002 18:33:31 +1200
"Sergiy" <sergiy@x...> wrote:
>I am writing some data into Excel spreadsheet. The code:
>
>Dim strSource As String = Server.MapPath("ExcelData1.xls") + ";"
>
> Dim m_sConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
>& "Data
>Source=" & strSource & _
> "Extended Properties=""Excel 8.0;HDR=YES"""
>
> Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
>
> Try
> conn1.Open()
> Dim cmd As New System.Data.OleDb.OleDbCommand()
> cmd.Connection = conn1
> cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name,
>BirthDate)
>values ('New', '111', '10/14/48')"
> cmd.ExecuteNonQuery()
> cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name,
>BirthDate)
>values ('New 2', 'Deloris 55', '7/19/98')"
> cmd.ExecuteNonQuery()
>
>. . .
>
>
>The code runs perfectly at one computer (Windows 2000 OS), but when I
>created the exactly the same application at another computer (with
>Windows
>XP OS) it gives an error:
>'System.Data.OleDb.OleDbException: Operation must use an updateable
>query.'
>The line: cmd.ExecuteNonQuery() caused the error.
>
>I believe that it caused by the security permissions,
>because when I copied the Excel file into folder "c:\aa" and set is
>as
>shared folder ,
>etc, the application run without any problem. I only changed the
>source
>path:
>Dim strSource As String = "C:\aa\ExcelData1.xls;"
>
>I tried: set permissions to write in IIS for this application, set
>ASPNet
>account for this folder with all permissions, but all the same.
>So which settings necessary to change to allow writing into the file?
>
>
---------------------------------------------
http://mail.indiainfo.com
India's first ISO certified portal
Check world time at http://time.indiainfo.com
|
|
 |