PC Review


Reply
Thread Tools Rate Thread

Accessing external DB, and making query

 
 
David Wessell
Guest
Posts: n/a
 
      30th Apr 2007
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 With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      30th Apr 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing <sic> External data Dave180 Microsoft Access VBA Modules 2 9th Dec 2008 09:58 AM
Accessing External Module sck352@gmail.com Microsoft Excel Programming 1 5th Feb 2008 09:20 PM
Accessing External Database =?Utf-8?B?TS4gV2lsc29u?= Microsoft Access 2 25th Jan 2006 06:55 PM
Making CD from external source =?Utf-8?B?QmVuamll?= Windows XP Music 3 10th Sep 2005 06:29 AM
Accessing External Data Jon Kane Microsoft Excel Programming 1 30th Oct 2003 01:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:22 PM.