English 中文(简体)
在Excel和OLEDB之间添加工作表格栏
原标题:Adding column to worksheet in Excel with OLEDB
  • 时间:2011-03-10 15:27:48
  •  标签:
  • excel
  • oledb

Hello
I m trying to add new column to the Excel worksheet by command

ALTER TABLE [MyTable] ADD COLUMN Field_dest nvarchar

But on execution of the command got exception "Invalid operation" I tried table name with and without $ at the end , but got the same result
My questions are
1) Is there some wrong in the command above?
2) Is command ALTER table supported for excel table ?
3) Is the alternative way to add column into excel worksheet - preferable via OLEDB ?

预 收

最佳回答

不过,法国家庭援助协会可以创建表格或选择Into,使你能够制作新的表格。 我不能从公开发言开始。

Dim cn As Object
Dim scn As String
Dim sSQL As String

strFile = "C:Docs	est.xls"

scn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
strFile & ";Extended Properties=""Excel 8.0;HDR=Yes;"""

Set cn = CreateObject("ADODB.Connection")

cn.Open scn

  Note that there is no $ on the sheet to be created
sSQL = "SELECT *,   As NewField INTO [Sheet17] FROM [Sheet4$]"

  Jet data types
sSQL = "CREATE TABLE [Sheet8] (AText text, ANother text)"

cn.Execute sSQL

如果你拿着公开档案的话,你就会犯错,说不存在。

问题回答

You can use Create Table instead of Alter Table. Just use your existing table name, then your columns adds to existing sheet

CREATE TABLE [ExistingSheet$] (ID char(255), oldField1 char(255), newField2 char(255))

工作!





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签