学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

vb.net读取不同数据的方式(1)

vb.net读取不同数据的方式(1)

用于读取text文档的数据
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Try
                Dim sr As New System.IO.StreamReader(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

TOP

有个问题请教下各们高手

在VB.NET中这个&符号有多少种用用途?

TOP

已阅~

TOP

发新话题