| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1149 人关注过本帖
标题:vb.net读取不同数据的方式(1)
只看楼主 加入收藏
ziyouyu
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-3-12
收藏
 问题点数:0 回复次数:2 
vb.net读取不同数据的方式(1)
用于读取text文档的数据
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Try
                Dim sr As New (OpenFileDialog1.FileName)
                Do While endof = False
                    vin = sr.ReadLine.Substring(0, 17)
                    SelectStr = "select * from saomiaovin where vin= '" & vin & "' "
                    Dim Resault As DataTable
                    Resault = AccessOperation.ACCESSOperate(SelectStr, msg)
                    If Resault.Rows.Count = 0 Then
                        'MsgBox(vin + "已经扫描过,将覆盖该VIN号")
                        InsertStr = "insert into saomiaovin values('" & vin & "') "
                        AccessOperation.ACCESSOperate(InsertStr, msg)
                    End If
                    endof = sr.EndOfStream
                Loop
                sr.Close()
                MsgBox("数据导入成功!")
            Catch
                MsgBox(Err.Description)
            End Try
        End If

读取excle的数据
If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim str As String = Me.OpenFileDialog1.FileName
            Dim cn As System.Data.OleDb.OleDbConnection
            Dim cmd As System.Data.OleDb.OleDbDataAdapter
            Dim ds As New System.Data.DataSet()
            MsgBox(str)
            cn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & _
                "data source= " & str & ";Extended Properties=Excel 8.0;")
            ' Select the data from Sheet1 of the workbook.
            cmd = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", cn)
            cn.Open()
            cmd.Fill(ds)
            cn.Close()
            Dim table As DataTable = ds.Tables(0)
            Me.DataGridView1.DataSource = table
        End If
搜索更多相关主题的帖子: vin 数据 Dim Resault 
2008-03-12 13:50
lao2005
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-3-12
收藏
得分:0 
有个问题请教下各们高手
中这个&符号有多少种用用途?
2008-03-13 20:56
chen_zixi
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2008-3-17
收藏
得分:0 
已阅~
2008-03-17 19:57
快速回复:vb.net读取不同数据的方式(1)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029905 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved