|
2015/7/20 下午 11:03:24
Microsoft Jet 資料庫引擎無法開啟 ' 檔案。它已經被其他的使用者獨佔地開啟,或者您需要有檢視資料的權限。 沒有開啟檔案時執行,也檢查過權限了..想請問各位高手如何解 ------------------------------------------------------- Imports System.Data.OleDb Imports System.IO Imports System.Text Imports System.Collections Imports System.Data.Odbc
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Using ofd As New OpenFileDialog ofd.Filter = "All files (*.*)|*.*" ofd.Title = "Select File"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then readfile(ofd.FileName)
End If End Using
End Sub Public Function readfile(ByVal filepath As String) As Integer Dim fileread As New StreamReader(filepath, System.Text.Encoding.GetEncoding("BIG5")) fileread.ReadLine() Dim count As Integer = 0 While Not fileread.EndOfStream Dim strline As String = fileread.ReadLine Dim strarray = strline.Split(";") DataGridView1.Rows.Add() For i As Integer = 0 To strarray.Length - 1 DataGridView1.Rows(count).Cells(i).Value = strarray(i) Next count += 1 End While Return 1 fileread.Close() End Function Private Sub Button2_Click_1(sender As System.Object, e As System.EventArgs) Handles Button2.Click Call ReadFileA() End Sub Private Sub ReadFileA()
Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ "D:\apple5.mdb;Persist" & _ " Security Info=False;") Dim sqlstr As String sqlstr = "INSERT INTO Missing_Lns SELECT * FROM [Text;HDR=No;FMT=Delimited;" & _ "Database=D:\;].123.txt;" cnn.Open() Dim cmd As New OleDbCommand(sqlstr, cnn) cmd.ExecuteNonQuery() cnn.Close()
End Sub
End Class
|
|
|
|
|
|
|
|
|
|
|
板主 :
Clark
Top 10 評價排行 |
 |
物件導向程式設計 |
|
|
|
|
|
|
|
|
|
物件導向程式設計 |
 |
|
|
專家等級 |
評價 |
|
|
一代宗師 |
10000 |
|
|
曠世奇才 |
5000 |
|
|
頂尖高手 |
3000 |
|
|
卓越專家 |
1500 |
|
|
優秀好手 |
750 |
|
|
|
|
|
|
|