dbTalk Databases Forums  

Writing to a Spreadsheet as you would a Database

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Writing to a Spreadsheet as you would a Database in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Todd Huttenstine
 
Posts: n/a

Default Writing to a Spreadsheet as you would a Database - 05-03-2004 , 11:00 PM






Hey guys

Ok I believe this is the correct news group I need to be in(I really hope
so)
I have been working on this problem now for 4 days. I am trying to simply
add a new record to a text spreadsheet. Its C:\TEST.XLS. It has 2 columns
(A and B) The name in A1 is AAA and B1 is BBB. Now from another workbook I
want to be able to add the record "testA" to column A and "testB" to Column
B. I have the following code but am receiving an error. See my code
below....

Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\TEST.XLS;" & _
"Extended Properties=Excel 8.0;"

' Create the SQL statement.
szSQL = "INSERT INTO Sheet1$" & _
"VALUES('testval1', 'testval2');"

' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing


Now I am receiving the Automation Error on the following line of code:
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords

How do I make this code work?


Thank you
Todd Huttenstine



Reply With Quote
  #2  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: Writing to a Spreadsheet as you would a Database - 05-04-2004 , 07:50 AM






As far as I know the driver doesn't support updates/inserts/deletes on Excel
files. You can use the Excel COM library to manipulate spreadsheets from VB.

--
Jacco Schalkwijk
SQL Server MVP


"Todd Huttenstine" <t.huttenstine (AT) charter (DOT) net> wrote

Quote:
Hey guys

Ok I believe this is the correct news group I need to be in(I really hope
so)
I have been working on this problem now for 4 days. I am trying to simply
add a new record to a text spreadsheet. Its C:\TEST.XLS. It has 2
columns
(A and B) The name in A1 is AAA and B1 is BBB. Now from another workbook
I
want to be able to add the record "testA" to column A and "testB" to
Column
B. I have the following code but am receiving an error. See my code
below....

Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\TEST.XLS;" & _
"Extended Properties=Excel 8.0;"

' Create the SQL statement.
szSQL = "INSERT INTO Sheet1$" & _
"VALUES('testval1', 'testval2');"

' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing


Now I am receiving the Automation Error on the following line of code:
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords

How do I make this code work?


Thank you
Todd Huttenstine





Reply With Quote
  #3  
Old   
Todd Huttenstine
 
Posts: n/a

Default Re: Writing to a Spreadsheet as you would a Database - 05-04-2004 , 03:20 PM



Hey how would I do this with COM? Do you happen to have a sample code for
just adding to a closed workbook? Any help is greatly appreciated.


Thank you
Todd Huttenstine


"Jacco Schalkwijk" <NOSPAMjaccos (AT) eurostop (DOT) co.uk> wrote

Quote:
As far as I know the driver doesn't support updates/inserts/deletes on
Excel
files. You can use the Excel COM library to manipulate spreadsheets from
VB.

--
Jacco Schalkwijk
SQL Server MVP


"Todd Huttenstine" <t.huttenstine (AT) charter (DOT) net> wrote in message
news:109e5bl53rvjjc2 (AT) corp (DOT) supernews.com...
Hey guys

Ok I believe this is the correct news group I need to be in(I really
hope
so)
I have been working on this problem now for 4 days. I am trying to
simply
add a new record to a text spreadsheet. Its C:\TEST.XLS. It has 2
columns
(A and B) The name in A1 is AAA and B1 is BBB. Now from another
workbook
I
want to be able to add the record "testA" to column A and "testB" to
Column
B. I have the following code but am receiving an error. See my code
below....

Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\TEST.XLS;" & _
"Extended Properties=Excel 8.0;"

' Create the SQL statement.
szSQL = "INSERT INTO Sheet1$" & _
"VALUES('testval1', 'testval2');"

' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing


Now I am receiving the Automation Error on the following line of code:
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords

How do I make this code work?


Thank you
Todd Huttenstine







Reply With Quote
  #4  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: Writing to a Spreadsheet as you would a Database - 05-07-2004 , 05:45 AM



I don't have anything handy, but if you ask for it on an Excel newsgroup,
you'll get something pretty quick.

--
Jacco Schalkwijk
SQL Server MVP


"Todd Huttenstine" <TDBilsborough (AT) Charter (DOT) net> wrote

Quote:
Hey how would I do this with COM? Do you happen to have a sample code for
just adding to a closed workbook? Any help is greatly appreciated.


Thank you
Todd Huttenstine


"Jacco Schalkwijk" <NOSPAMjaccos (AT) eurostop (DOT) co.uk> wrote in message
news:uJIXNZdMEHA.3380 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
As far as I know the driver doesn't support updates/inserts/deletes on
Excel
files. You can use the Excel COM library to manipulate spreadsheets from
VB.

--
Jacco Schalkwijk
SQL Server MVP


"Todd Huttenstine" <t.huttenstine (AT) charter (DOT) net> wrote in message
news:109e5bl53rvjjc2 (AT) corp (DOT) supernews.com...
Hey guys

Ok I believe this is the correct news group I need to be in(I really
hope
so)
I have been working on this problem now for 4 days. I am trying to
simply
add a new record to a text spreadsheet. Its C:\TEST.XLS. It has 2
columns
(A and B) The name in A1 is AAA and B1 is BBB. Now from another
workbook
I
want to be able to add the record "testA" to column A and "testB" to
Column
B. I have the following code but am receiving an error. See my code
below....

Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\TEST.XLS;" & _
"Extended Properties=Excel 8.0;"

' Create the SQL statement.
szSQL = "INSERT INTO Sheet1$" & _
"VALUES('testval1', 'testval2');"

' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing


Now I am receiving the Automation Error on the following line of code:
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords

How do I make this code work?


Thank you
Todd Huttenstine









Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.