首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SQL Server 2008导入数据向导无法识别列的整数数据

SQL Server 2008导入数据向导无法识别列的整数数据
EN

Stack Overflow用户
提问于 2010-02-03 23:23:24
回答 2查看 905关注 0票数 0

我有一个有10列标题的excel表格。对于列,我可以将数据设置为"FF5“或Else620。图纸名称为IODE。

我正在尝试将此数据从SSIS import data向导导入到表IODE的数据库中。

在向导中选择源和目标时,当我单击Select source Tables and Views窗口中的预览数据时,我看到列620为null。导入此数据后,表将具有NULL而不是620。

表中此列的数据类型为nvarchar(50),我尝试了许多数据类型,如varchar(100)、text/..

只接受字母数字数据。

我没有为此编写任何代码..我只是想把数据从excel表格导入到表格中。

请帮我解决这个问题

谢谢拉姆

EN

回答 2

Stack Overflow用户

发布于 2010-02-03 23:26:40

您的意思是,您有FF5或620作为该列的值,这意味着您有一个或另一个,而没有其他值,或者该列中也有空白字段?

票数 0
EN

Stack Overflow用户

发布于 2010-02-04 17:51:01

我尝试使用VB6.0中的excel库引用来读取Excel。

因为在将数据导出到SQL表时,SSIS导入向导会将NUMERIC视为NULL。

此过程非常适用于数据插入和其他数据库操作。

Error GoTo errHandler上的

私有子AccessExcelData()

Dim oXLApp As Excel.Application‘声明对象变量

Dim oXLBook As Excel.Workbook

Dim oXLSheet As Excel.worksheet

Dim strFileName As String

Dim lCount As Long

Dim strSCDName As String

Dim strICDName As String

作为整数的Dim intSource_Index

Dim strInput_Port As String

Dim strLabel As String

Dim strSDI_CID As String

作为整数的Dim intWordBitNO

Dim strFilter_Type As String

Dim strPgroup_Input As String

Dim strParagraph_Input As String

Dim strSQL As String Dim sConnString As String

作为新ADODB.Connection的Dim cnTest

作为新ADODB.Recordset的Dim rsTempRecordset

作为新FmmtDataAccess.clsDataAccess的Dim objDataAccess

Dim strxmlResult As String

objDataAccess.Intialize ConString

strFileName = App.Path & "\IODE.xls“

sConnString = "Server=uasql\commonsql;Database=accounts;Driver=SQL Server;Trusted_Connection=Yes;DSN=uasql\commonsql“

使用cnTest

代码语言:javascript
运行
复制
   .ConnectionString = sConnString
代码语言:javascript
运行
复制
   .ConnectionTimeout = 4
代码语言:javascript
运行
复制
   .CursorLocation = adUseClient
代码语言:javascript
运行
复制
   .Open

结尾为

‘创建excel工作表的一部分。

设置oXLApp = CreateObject("Excel.Application")

‘创建Excel的新实例

oXLApp.Visible = False

‘不将其显示给用户

Set oXLBook = oXLApp.Workbooks.Open(strFileName)‘打开现有工作簿

Set oXLSheet = oXLBook.Worksheets(1)‘使用第一个工作表oXLSheet.Activate

使用oXLApp

对于lCount =2到oXLSheet.UsedRange.Rows.Count

strSCDName = .Cells(lCount,1).Value

strICDName = .Cells(lCount,2).Value

intSource_Index = .Cells(lCount,3).Value

strInput_Port = .Cells(lCount,4).Value

strLabel = .Cells(lCount,5).Value

strSDI_CID = .Cells(lCount,6).Value

intWordBitNO = .Cells(lCount,7).Value

strFilter_Type = .Cells(lCount,8).Value

strPgroup_Input = .Cells(lCount,9).Value

strParagraph_Input = .Cells(lCount,10).Value

'strSQL = "Insert into XYX () values (strSCDName ..... )这里可以使用任何与数据库相关的查询

rsTempRecordset.Open strSQL,cnTest,adOpenForwardOnly,adLockReadOnly Next

结尾为

‘关闭excel工作表的一部分。

oXLApp.Visible = False‘不将其显示给用户

Set oXLSheet = Nothing‘断开与所有Excel对象的连接(让用户接管)

oXLBook.Close SaveChanges:=False‘保存工作簿(与工作簿断开连接)

设置oXLBook = Nothing

oXLApp.Quit关闭(和断开) Excel

设置oXLApp = Nothing

退出SuberrHandler:

MsgBox Err.Description

Screen.MousePointer = vbNormalEnd Sub

利用此过程,可以从vb应用程序中读取excel记录,并将其插入到SQL数据库中已有的表中。谢谢拉姆

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2193004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档