OleDb数据提取有问题 [英] Trouble with OleDb data extract

查看:83
本文介绍了OleDb数据提取有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个不寻常的问题,只是在一个漂亮的

糟糕的时间里表现出丑陋的头脑。我有一个asp.net(VB)应用程序,它从Excel

工作表中获取数据并将其放入SQL Server。我使用

OleDB从Excel中获取数据,突然之间,一些数据没有从

Excel中提取出来。


我使用OleDb将数据提取到DataTable中,并从那里获得一个
SqlClient.SqlCommand将它放入SQL Server。


我把结果将OleDb提取到数据网格中以查看是否存在

问题或SqlClient插入。数据网格显示

缺少数据,甚至在我进入SQL插入之前。这是我的代码

(大致):


Dim sConnectionString As String =" Provider = Microsoft.Jet.OLEDB.4.0;" < br $> b $ b _

& 数据源= TEST.XLS" _

&英寸;" &安培; Extended Properties = Excel 8.0;"

Dim objConnXL As New OleDbConnection(sConnectionString)

''''''''创建数据适配器和数据集。

昏暗的员工选择新的OleDbCommand(SELECT * FROM

员工,其中RowNum> 0",objConnXL)

昏暗的员工适配器作为新的OleDbDataAdapter()

员工Adapter.SelectCommand =员工选择

昏暗的员工数据集作为新的DataSet()

员工适配器。填写(员工数据集,XLData)


''DataGrid1.DataSource = Employee Dataset.Tables(0).DefaultView

''DataGrid1.DataBind ()

从名为Employee的Excel命名空间中假设以下数据:


First Last Addr City State Zip RowNum

Joe Smith 123 Main NY NY 12345 1

Bill Jones 456 North LA CA 54321 2

摘录突然省略了拉链12345,但显示了其他13

馅饼数据很好。我可以在Excel表格中看到数据。这已经好几个月工作了很好,当然,上周我们去了b / b
生活,去看看。


如果有人碰到这个或类似的东西,请大喊大叫。


谢谢。

Hi,

I have an unusual problem that just showed its ugly head at a pretty
bad time. I have an asp.net (VB) app that takes data from an Excel
sheet and puts it into SQL Server. I get the data out of Excel using
OleDB, and suddenly, some of the data was not being extracted from
Excel.

I use OleDb for the extract into a DataTable and from there an
SqlClient.SqlCommand to put it into SQL Server.

I put the results of the OleDb extract into a datagrid to see if the
problem was there or the SqlClient insert. The datagrid showed
missing data, even before I got to the SQL insert. Here''s my code
(roughly):

Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
_
& "Data Source = " test.xls" _
& ";" & "Extended Properties=Excel 8.0;"
Dim objConnXL As New OleDbConnection(sConnectionString)

''''''''Create Data Adapter and Data Set.
Dim Employee Select As New OleDbCommand("SELECT * FROM
Employee where RowNum > 0 ", objConnXL)
Dim Employee Adapter As New OleDbDataAdapter()
Employee Adapter.SelectCommand = Employee Select
Dim Employee Dataset As New DataSet()
Employee Adapter.Fill(Employee Dataset, "XLData")

''DataGrid1.DataSource = Employee Dataset.Tables(0).DefaultView
''DataGrid1.DataBind()
Assume the following data from an Excel namespace called Employee:

First Last Addr City State Zip RowNum
Joe Smith 123 Main NY NY 12345 1
Bill Jones 456 North LA CA 54321 2
The extract suddenly omitted the zip 12345, but displayed the other 13
pieces of data fine. I can see the data in the Excel sheet. This has
been working fine for several months, and of course, last week we went
live, go figure.

If anyone has run into this or anything like it, please give a yell.

Thanks.

推荐答案

嗨Brian,


我不确定提取物突然省略了

zip 12345的确切含义,但显示了其他13件数据很好。正如我理解,你的意思是你失去了第一排。请删除where

RowNum> 0"并再次测试这个问题。


此外,我相信以下文章对您有用。请

请仔细参考。


从ASP.NET读取Excel文件
http://www.aspfree.com/examples/766,1/examples.aspx

" ...

此页面提供了一个简单的示例,说明如何使用C#或VB从ASP.NET页面查询Excel电子表格

。 NET。

..."


如果我误解了您的疑虑,请随时告诉我。


祝你好运,


Jacob Yang

微软在线合作伙伴支持

安全! - www.microsoft.com/security

发布是按原样提供的。没有保证也没有授予任何权利。

Hi Brian,

I am not sure about the exact meaning of "The extract suddenly omitted the
zip 12345, but displayed the other 13 pieces of data fine." As I
understand, you mean that you lost the first row. Please remove "where
RowNum > 0" and test this issue again.

In addition, I believe that the following article is useful to you. Please
refer to it carefully.

Read Excel files from ASP.NET
http://www.aspfree.com/examples/766,1/examples.aspx
"...
This page provides a simple example of how to query an Excel spreadsheet
from an ASP.NET page using either C# or VB.NET.
..."

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


嗨Brian,


我不确定确切含义提取物突然省略了

zip 12345,但显示其他13个数据正常。正如我理解,你的意思是你失去了第一排。请删除where

RowNum> 0"并再次测试这个问题。


此外,我相信以下文章对您有用。请

请仔细参考。


从ASP.NET读取Excel文件
http://www.aspfree.com/examples/766,1/examples.aspx

" ...

此页面提供了一个简单的示例,说明如何使用C#或VB从ASP.NET页面查询Excel电子表格

。 NET。

..."


如果我误解了您的疑虑,请随时告诉我。


祝你好运,


Jacob Yang

微软在线合作伙伴支持

安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有赋予任何权利。

Hi Brian,

I am not sure about the exact meaning of "The extract suddenly omitted the
zip 12345, but displayed the other 13 pieces of data fine." As I
understand, you mean that you lost the first row. Please remove "where
RowNum > 0" and test this issue again.

In addition, I believe that the following article is useful to you. Please
refer to it carefully.

Read Excel files from ASP.NET
http://www.aspfree.com/examples/766,1/examples.aspx
"...
This page provides a simple example of how to query an Excel spreadsheet
from an ASP.NET page using either C# or VB.NET.
..."

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.





雅各布,


感谢您的回复。我的意思是提取物突然省略了

zip 12345,但显示其他13条数据没问题?这是。


假设Excel数据如下所示:

第一个上一个地址城市州邮编RowNum

Joe Smith 123 Main NY NY 12345 1

Bill Jones 456 North LA CA 54321 2

然后假设数据网格从Excel工作表中选择所有内容

看起来像这样:


First Last Addr City State Zip RowNum

Joe Smith 123 Main NY NY 1

Bill Jones 456 North LA CA 54321 2

所有数据均从Excel表格中选择,但一个字段除外。


谢谢。

** *通过开发人员指南 http://www.developersdex.com 发送***

不要只是参加USENET ......获得奖励!


Hi Jacob,

Thanks for the reply. What I meant by "The extract suddenly omitted the
zip 12345, but displayed the other 13 pieces of data fine? is this.

Assume the Excel data looking like this:

First Last Addr City State Zip RowNum
Joe Smith 123 Main NY NY 12345 1
Bill Jones 456 North LA CA 54321 2
Then assume the datagrid that selects everything from the Excel sheet
looks like this:

First Last Addr City State Zip RowNum
Joe Smith 123 Main NY NY 1
Bill Jones 456 North LA CA 54321 2
All data is selected from the Excel sheet except for one field.

Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


这篇关于OleDb数据提取有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆