기존의 Excel 양식을 변경하여 SLQ 서버에 레코드를 제공하기 위해 노력하고 있습니다.Excel 2003 VBA SQL Server 2000에 쓰기 ADO
DSN 및 ODBC를 사용하여 캡처를 제거하고 서버에 데이터를 쓰는 코드로는 매우 성공적이었습니다. (많은있다 느릅)
scn = dsn=ODBC123
목표 사용자 엑셀 2003 사용하고 각각의 터미널에 연결 ODBC 실용적이지 않다.
이것은 ADODB를 사용하는 첫 번째 벤처입니다.
내가 badSQL 메시지를 보냈지 만 UID와 패스를 추가 할 때까지 서버에서 오류가 발생하지 않았습니다. 고급 여성 및/또는 여러분이 살펴보고 몇 가지 guidence을 제공 자동화 오류 지정되지 않은 오류 당신의
겠습니까 하나
는 지금은 런타임 오류 '-2147467559 (80004005)'는 무엇입니까?
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim ssql As String
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Const scn As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog="DB on Server";" & _
"Data Source="Server Name" & _
"User ID=Form;Password=nope;"
ssql = "sql statment that writes a record to a table using info in the excel form," & _
" writen in vb that has worked through an odbc"
With cn
.CursorLocation = adUseClient
.Open scn
.CommandTimeout = 0
Set rst = .Execute(ssql)
End With
On Error GoTo badsql:
rs.Open ssql, cn, adOpenStatic, adLockOptimistic
On Error GoTo badsql:
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
MsgBox ("This record was updated in the database and documented for" & _
" processing. Please close this workbook.")
badsql:
MsgBox ("This record was not processed please resubmit.")
Exit Sub'
감사 Barrowc보다
cn.Execute
를 사용하려면,INSERT
타입 쿼리를 것으로 보인다로서, 한 번 쿼리 문자열을 실행하려면 그러나 첫 번째와 rs는 문제였다. –