edderic
Programmer
- May 8, 1999
- 628
import Table (access2000) with VB-code to a external access2000 database,what's wrong with this code :<br>
<br>
<br>
Private Sub Command1_Click()<br>
<br>
Dim cnn1 As ADODB.Connection<br>
Dim cmdQuery As ADODB.Command<br>
Dim strCnn As String<br>
Dim Rs1 As ADODB.Recordset<br>
Dim prm As ADODB.Parameter<br>
<br>
Dim First, UserPath As String<br>
On Error GoTo ErrorHandler<br>
<br>
sTable = List2.List(0)<br>
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="<br>
strCnn = strCnn & sTmp<br>
<br>
Set cnn1 = New ADODB.Connection<br>
cnn1.Open strCnn<br>
<br>
Set cmdQuery = New ADODB.Command<br>
Set Rs1 = New ADODB.Recordset<br>
Set cmdQuery.ActiveConnection = cnn1<br>
<br>
SelectString = "SELECT * INTO"<br>
FromString = "FROM"<br>
FromSource = sTmp<br>
NewTable = Text7.Text<br>
<br>
SQLtext = SelectString & Space(1) & "[" & Destination & "]" _<br>
& "." & NewTable & Space(1) & FromString & Space(1) _<br>
& "[" & FromSource & "]" & "." & sTable<br>
<br>
cmdQuery.CommandText = SQLtext<br>
<br>
Set Rs1 = cmdQuery.Execute()<br>
<br>
If Err.Number = 0 Then<br>
MsgBox "De Tabel is geimporteerd", vbOKOnly, "Bericht aan gebruiker"<br>
End If<br>
<br>
cnn1.Close<br>
Exit Sub<br>
<br>
<br>
<br>
ErrorHandler:<br>
Select Case Err.Number<br>
Case Else<br>
<br>
Msg = "Unexpected error #" & Str(Err.Number)<br>
Msg = Msg & " occurred: " & Err.Description<br>
<br>
MsgBox Msg, vbCritical<br>
<br>
End Select<br>
Resume Next<br>
End Sub<br>
<br>
Eric<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>
<br>
<br>
Private Sub Command1_Click()<br>
<br>
Dim cnn1 As ADODB.Connection<br>
Dim cmdQuery As ADODB.Command<br>
Dim strCnn As String<br>
Dim Rs1 As ADODB.Recordset<br>
Dim prm As ADODB.Parameter<br>
<br>
Dim First, UserPath As String<br>
On Error GoTo ErrorHandler<br>
<br>
sTable = List2.List(0)<br>
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="<br>
strCnn = strCnn & sTmp<br>
<br>
Set cnn1 = New ADODB.Connection<br>
cnn1.Open strCnn<br>
<br>
Set cmdQuery = New ADODB.Command<br>
Set Rs1 = New ADODB.Recordset<br>
Set cmdQuery.ActiveConnection = cnn1<br>
<br>
SelectString = "SELECT * INTO"<br>
FromString = "FROM"<br>
FromSource = sTmp<br>
NewTable = Text7.Text<br>
<br>
SQLtext = SelectString & Space(1) & "[" & Destination & "]" _<br>
& "." & NewTable & Space(1) & FromString & Space(1) _<br>
& "[" & FromSource & "]" & "." & sTable<br>
<br>
cmdQuery.CommandText = SQLtext<br>
<br>
Set Rs1 = cmdQuery.Execute()<br>
<br>
If Err.Number = 0 Then<br>
MsgBox "De Tabel is geimporteerd", vbOKOnly, "Bericht aan gebruiker"<br>
End If<br>
<br>
cnn1.Close<br>
Exit Sub<br>
<br>
<br>
<br>
ErrorHandler:<br>
Select Case Err.Number<br>
Case Else<br>
<br>
Msg = "Unexpected error #" & Str(Err.Number)<br>
Msg = Msg & " occurred: " & Err.Description<br>
<br>
MsgBox Msg, vbCritical<br>
<br>
End Select<br>
Resume Next<br>
End Sub<br>
<br>
Eric<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>