Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Accessing external DB, and making query

Hi,

I'm new to VBA (Although I do have programming experience in other
languages).. I'm getting my feet wet, and trying to make a DB query to
a Firebird DB.

So far I have:

Dim dbMain As New ADODB.Connection
Dim rs As New ADODB.Recordset
dbMain.Open "DRIVER=Firebird/InterBase(r)
driver;UID=SYSDBA;PWD=masterkey;DBNAME=c:\temp.fdb "

rs.Open "SELECT sum(total_price) FROM headers", dbMain, adOpenKeyset,
adLockPessimistic

Dim tmp As Double
tmp = rs!Sum(total_price)
Sheets("Sheet1").Range(A1) = rs!Sum
-----

My problem is I'm not sure if rs.Open is retrieving the value, and
then the lines following where I attempt to assign that value have a
type mismatch.. I'm thinking it's becuase nothing is being returned in
the record set..

Can someone set me on the right path?

Thanks
David

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Accessing external DB, and making query

I think you need to do:

Dim tmp As Double
tmp = rs.Fields(0)
Sheets("Sheet1").Range(A1) = tmp

Or just:

Sheets("Sheet1").Range(A1) = rs.Fields(0)

RBS

"David Wessell" wrote in message
ps.com...
Hi,

I'm new to VBA (Although I do have programming experience in other
languages).. I'm getting my feet wet, and trying to make a DB query to
a Firebird DB.

So far I have:

Dim dbMain As New ADODB.Connection
Dim rs As New ADODB.Recordset
dbMain.Open "DRIVER=Firebird/InterBase(r)
driver;UID=SYSDBA;PWD=masterkey;DBNAME=c:\temp.fdb "

rs.Open "SELECT sum(total_price) FROM headers", dbMain, adOpenKeyset,
adLockPessimistic

Dim tmp As Double
tmp = rs!Sum(total_price)
Sheets("Sheet1").Range(A1) = rs!Sum
-----

My problem is I'm not sure if rs.Open is retrieving the value, and
then the lines following where I attempt to assign that value have a
type mismatch.. I'm thinking it's becuase nothing is being returned in
the record set..

Can someone set me on the right path?

Thanks
David


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table accessing external data Jwaltb Excel Discussion (Misc queries) 6 February 22nd 07 06:04 PM
Accessing external database causing problems? Michael Malinsky Excel Programming 1 December 21st 05 09:30 PM
Accessing external test equipment using Excel RichardG Excel Programming 3 November 30th 04 11:22 PM
Error accessing external object property vbe NilovSerge Excel Programming 1 June 21st 04 12:48 PM
Accessing External Data Jon Kane Excel Programming 1 October 30th 03 01:52 PM


All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"