从xcel读取的问题 [英] problem with reading from xcel

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

问题描述

请帮助我正在开发一个从不同形式的数据库收集数据的系统,并且我已经能够使用vb.net实现4(mysql,xml,....)5,现在是最后一个是从excel表获取数据,但代码不起作用..请我将不胜感激任何解决方案



这是我的代码:::

pls help am working on a system that collects data from different forms of database and i have been able to implement 4 (mysql,xml,....)out 5 using vb.net and now am on the last one which is getting data from an excel sheet but the code aint working .. please i would be grateful for any solutions

this is my code :::

Dim olecon As OleDbConnection
Dim olecomm As OleDbCommand
 

Try
olecon = New OleDbConnection
olecon.ConnectionString = connstring_busary
'connection_busary is a variable the stores the conection string
olecon.Open()
olecomm = New OleDbCommand(String.Format("SELECT * FROM [sheet1$]"), olecon)
 
Dim reading As OleDbDataReader = olecomm.ExecuteReader()
 

           While (reading.Read)
           If Not reading.IsDBNull(reading.GetOrdinal("A7")) Then
                Label1.Text = reading.GetString(reading.GetOrdinal("A7"))
                
                End If
 

            End While
 
        Catch ex As OleDb.OleDbException
            MessageBox.Show(ex.Message)
        End Try
 

    End Sub





当我运行此代码时它只运行并且不返回任何我用来跟踪从excel文件返回任何值的标签的值...我需要帮助竖起大拇指| :thumbsup:



when ever i run this code it just runs and does not return any value to the label i used to track if any value is been returned from the excel file ... please i need help Thumbs Up | :thumbsup:

推荐答案

),olecon)

Dim reading As OleDbDataReader = olecomm.ExecuteReader()


while(reading.Read)
如果不读取.IsDBNull(reading.GetOrdinal(A7))那么
Label1.Text = reading.GetString(reading.GetOrdinal(A7) ))

结束如果


结束时

Catch ex As OleDb.OleDbException
MessageBox.Show(例如。消息)
结束尝试


结束子
"), olecon) Dim reading As OleDbDataReader = olecomm.ExecuteReader() While (reading.Read) If Not reading.IsDBNull(reading.GetOrdinal("A7")) Then Label1.Text = reading.GetString(reading.GetOrdinal("A7")) End If End While Catch ex As OleDb.OleDbException MessageBox.Show(ex.Message) End Try End Sub





当我运行这个代码它只是运行,并没有返回任何值,我用来跟踪从excel文件返回任何值...我需要帮助竖起大拇指|:thumbsup:



when ever i run this code it just runs and does not return any value to the label i used to track if any value is been returned from the excel file ... please i need help Thumbs Up | :thumbsup:


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

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