把conn.open 開的Driver (Connect 字串改一下)
Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\Test.xls;" & _
"Extended Properties=Excel 8.0
就行嚕~
"阿寶" 來函:
> 我的問題:VB6回應Query Cannot be updated because it contains no searchable columns
> to use as a key.
> 但我不太了解它的意思,且我不知道Rs(0)我都讀得出來內容值[表路徑檔案正確],但怎麼寫不進去呢?是哪發生問題了!?
> 請各位先進解答,謝謝~
> 我的程式如下:
>
> Dim Driver, DBPath, SQL As String
> Dim Conn, Rs As Object
> Dim SQL As String
>
> Set Conn = CreateObject("ADODB.Connection")
> Set Rs = CreateObject("ADODB.Recordset")
>
> Driver = "DRIVER=Microsoft Excel Driver (*.xls);DBQ="
> DBPath = App.Path & ("\test.xls")
> Conn.open Driver & DBPath & ";ReadOnly=1"
>
> SQL = "select * from [sheet1$]"
> Rs.open SQL, Conn, 3, 3
>
> Rs.addnew
> Rs(0) = 1
> Rs(1) = 2
>
> Rs.Update 'Error 處
>
> '----- close -----
> Rs.Close
> Conn.Close
> Set Rs = Nothing
> Set Conn = Nothing