View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Candyman Candyman is offline
external usenet poster
 
Posts: 66
Default SQL Insert Statement to return "13620 row(s) affected."

Thanks for all your help. Sorry for the delayed response..

Have a great day!

" wrote:

Yo Candyman,

Yeah, once you're on board with DAO you'll wonder why you ever used MS
Query ....


I am getting a "User defined type not defined" error with the line:
Public Function GetConnection(db As DBConnection) As ADODB.connection
highlighted


You have to determine if Excel can't find DBConnection or ADODB.

1. Confirm that you post the DBConnection information into a class
module.(In your project you should have MS Excel Objects,
Forms,Modules, Class Modules (and DBConnection should be a Class
Module).

2. Confirm that Excel is referencing "Microsoft DAO 3.6 Object
Library" or so 3.51 - whatever version you've got.

I am trying to run a test macro but I am not sure how to envoke the 'db' part of your function using:


Try:

Public Function GetConnectionInfo() as DBConnection
Dim db as New DBConnection
db.server = "yourserver"
db.database = "yourdatabase"
db.userName = "yourusername"
db.password = "yourPassword"
Set GetConnectionInfo = db
End Function

Sub test()
Dim str, book, WSname , myDb As String
Dim myDB as DBConnection
Dim x as Integer
myDB = GetConnectionInfo()
book = ActiveWorkbook.Name
WSname = "TEMP"
SQL = "select * from HEIDS.HE_ACAPS_LOCS"
x= SelectData(book, myDB, SQL, WSname)
End Sub