Hi,
This is my first try at Ado and I have run into an issue. I am trying to run a maketable query in one Access database to create a table in a different Access database. When I run my code, I don't receive any errors but the table isn't created either. And before you ask; yes, I am looking in the database in the \bin\Debug folder.
This is my code in the form:
This is my code to open the database:
And here is my code to run the sql statement:
I got almost all of this code from Microsoft Help but I'm thinking the examples left out something that I missed. As I said, when I run this I get no errors but I get no table either.
ANY help would be greatly appreciated.
This is my first try at Ado and I have run into an issue. I am trying to run a maketable query in one Access database to create a table in a different Access database. When I run my code, I don't receive any errors but the table isn't created either. And before you ask; yes, I am looking in the database in the \bin\Debug folder.
This is my code in the form:
VB.NET:
Private Sub btnAssoc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAssoc.Click
ggAdo.ConnectionString = dbsAc <database connection string>
ggAdo.SqlStatement = "SELECT tblAssocInfo.Acid, tblAssocInfo.FirstName, tblAssocInfo.LastName, tblAssocInfo.MgrFull, " & _
"tblAssocInfo.Bucket, tblAssocInfo.Department " & _
"INTO tblAssoc " & _
"IN 'C:\z_GG Project\_Library\z_Test\Adox_1\bin\Debug\ggTest.mdb' " & _
"FROM tblAssocInfo;"
ggAdo.RunSqlStatement() <below>
MessageBox.Show("Complete", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
This is my code to open the database:
VB.NET:
Private Function OpenDatabase() As Boolean
Try
adoConn = New ADODB.Connection
adoConn.Open(ConnectionString)
Catch ex As Exception
MessageBox.Show("Dbs Open Failed: " & ex.ToString, "Dbs Open Fail", MessageBoxButtons.OK, MessageBoxIcon.Error)
OpenDatabase = False
Exit Function
End Try
End Function
And here is my code to run the sql statement:
VB.NET:
Public Function RunSqlStatement() As Boolean
Dim runFound As Boolean = False
Dim runProc As ADOX.Procedure
If OpenDatabase() = True Then <open database above>
adoCat = New ADOX.Catalog
adoCat.ActiveConnection = adoConn
adoCmd = New ADODB.Command
adoCmd.CommandText = SqlStatement (class property)
For Each runProc In adoCat.Procedures
If runProc.Name = "ggSql" Then
runFound = True
Exit For
End If
Next
If runFound = False Then
adoCat.Procedures.Append("ggSql", adoCmd)
End If
adoCmd = CType(adoCat.Procedures("ggSql").Command, Command)
adoCat.Procedures("ggSql").Command = adoCmd
adoCat = Nothing
adoCmd = Nothing
adoConn = Nothing
End If
End Function
I got almost all of this code from Microsoft Help but I'm thinking the examples left out something that I missed. As I said, when I run this I get no errors but I get no table either.
ANY help would be greatly appreciated.