コメント |
http://lightbox.cocolog-nifty.com/photos/app/ref_studio.png
http://lightbox.cocolog-nifty.com/photos/app/ref_adodb_2.png
↓商品分類マスタ.xls
http://lightbox.on.coocan.jp/download/syobun_xls.lzh
[[Excel 参照]]
@DIV
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' exe が存在するディレクトリ
Dim ProgPath As String = Application.StartupPath
Dim ExcelPath As String = ProgPath & "\商品分類マスタ.xls"
Dim ConnectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ExcelPath & ";" & _
"Extended Properties=""Excel 8.0;IMEX=1;"""
Dim Cn As ADODB.Connection = New Connection()
Try
Cn.Open(ConnectionString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try
Dim Rs As ADODB.Recordset = New Recordset()
Dim Query As String = "select * from [商品分類マスタ]"
Try
Rs.Open(Query, Cn)
Catch ex As Exception
MessageBox.Show(ex.Message)
Cn.Close()
Exit Sub
End Try
Dim Buffer As String = ""
Do While Not Rs.EOF
For i As Integer = 0 To Rs.Fields.Count - 1
If i <> 0 Then
Buffer = Buffer & ","
End If
Buffer = Buffer & Rs.Fields(i).Value
Next
Buffer = Buffer & ControlChars.CrLf
Rs.MoveNext()
Loop
Rs.Close()
Cn.Close()
MessageBox.Show(Buffer)
End Sub
@END
|