读取数据并将其存储在

读取数据并将其存储在

本文介绍了从Excel读取数据并将其存储在Sql服务器数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

任何人都可以帮助我,并告诉我如何解决以下问题:

我有一张Excel工作表.我需要从Excel工作表中读取数据.字段是制造商,零件号,描述和价格.我需要帮助来从Excel工作表中读取数据并将其存储在基于制造商和零件号的sqlserver数据库中.

我试图实现逻辑,但是当我从Excel工作表中读取数据并将其分配给数据集时,我遇到了问题.
问题1:
显示了行数2754,但是在我的excel工作表中只有5行可用.

OleDbConnection oledbCon =新的OleDbConnection(strCon);
oledbCon.Open();
OleDbCommand oledbCmd = oledbCon.CreateCommand();
oledbCmd.CommandText =选择*来自[Sheet1 $]";
DataSet ds = new DataSet();
OleDbDataAdapter oledbDa =新的OleDbDataAdapter(oledbCmd);
oledbDa.Fill(ds,"TempExcel");
ds.Tables [0] .Rows.Count

问题2:
如果Excel工作表中的价格字段包含字母letter,则当我从价格字段中获取记录时,它显示为空值.

Hi Friends,

Anyone please help me and tell me how to resolve the issues mentioned below:

I got an Excel sheet. I need to read data from excel sheet. Fields are manufacturer, partnumber, description, and price. I need help to read the data from Excel sheet and store it in a sqlserver database based on the manufacturer and partnumber.

I was trying to implement the logic but when I read the data from excel sheet and assign it into dataset i face issues.
Issue 1:
The row count 2754 is shown, but in my excel sheet only 5 rows are available.

OleDbConnection oledbCon = new OleDbConnection(strCon);
oledbCon.Open();
OleDbCommand oledbCmd = oledbCon.CreateCommand();
oledbCmd.CommandText = "SELECT * FROM [Sheet1$]";
DataSet ds = new DataSet();
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCmd);
oledbDa.Fill(ds, "TempExcel");
ds.Tables[0].Rows.Count

Issue 2:
If price fields in Excel sheet contains alphabet leter, when I fetch the record from price field it shows null value.

推荐答案




这篇关于从Excel读取数据并将其存储在Sql服务器数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 06:16