Use ASP to Insert a Record Into Excel 2007

I am trying to find out how to insert a record into  a excel 2007 workbook. I have a sheet called Requests that I would just like to add a new row to when I run my script but I can't figure out the proper syntax. I have attached my current code.
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.open"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\Inetpub\\db\\OfficeSpaceSummary.xlsx; Extended Properties=""Excel 12.0 Xml; HDR=YES; IMEX=1"";"
Set RS=Server.CreateObject("ADODB.recordset")
RS.Open "INSERT INTO [Requests$] (FirstName) VALUES ('1')"
RS.Close
Set RS = Nothing
oConn.Close

Open in new window

AludaanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Please check the example

For more examples pease check the following URL:
http://support.microsoft.com/kb/247412
  'Create a new connection object for Book1.xls
   Dim conn As New ADODB.Connection
   conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
      "Data Source=C:\Book1.xlsx;Extended Properties=Excel 12.0;"
   conn.Execute "Insert into MyTable (FirstName, LastName)" & _
      " values ('Scott', 'Brown')"
   conn.Execute "Insert into MyTable (FirstName, LastName)" & _
      " values ('Jane', 'Dow')"
   conn.Close

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AludaanAuthor Commented:
Hello O,

Thank you for the answer, but when I try to run that I get the following error:
Microsoft VBScript compilation  error '800a0401'

Expected end of statement

/scripts/Kiran/billstest.asp, line 2

Dim oConn as New ADODB.Connection
----------^

When I looked up the error I just keep hearing that it means I am not running asp.net, but I checked my system and asp.net 1.1.4322 is enabled. I have asp.net v2.0.50727 as well, but it is prohibited right now. I did turn it on to see if it would help, but it did not. Do you know what may be causing this problem?
0
Om PrakashCommented:
Please check the updated code:
'Create a new connection object for Book1.xls    
   Set oConn = Server.CreateObject("ADODB.Connection") 
   conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Book1.xlsx;Extended Properties=Excel 12.0;" 
   Set RS=Server.CreateObject("ADODB.recordset") 
   RS.Open "INSERT INTO [Requests$] (FirstName) VALUES ('1')" 
   RS.Close 
   Set RS = Nothing 
   oConn.Close

Open in new window

0
Om PrakashCommented:
Modified Code. This should work..
'Create a new connection object for Book1.xls 
Set oConn = Server.CreateObject("ADODB.Connection") 
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Book1.xlsx;Extended Properties=Excel 12.0;" 
conn.Execute "Insert into MyTable (FirstName, LastName) values ('Scott', 'Brown')" 
conn.Execute "Insert into MyTable (FirstName, LastName) values ('Jane', 'Dow')" 
conn.Close

Open in new window

0
AludaanAuthor Commented:
It turns out to be some sort of permission errors but only on one folder in the whole site. Not sure why that is, but it is something we will resolve in the future. Thank you for your help OM.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.