View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Junior728 Junior728 is offline
external usenet poster
 
Posts: 44
Default Problem with set OpenDataBase Statement in SQL

Hi Guys,

I have some problem with declaring the address for my Database. If it is
from a worksheet source or access DB, it will be easier, but it is from the
SQL server..how should i write it in the brackets(See arterisk statement)?
example codes below.

ThisWorkbook.Activate

'Open the database
Set dbs = OpenDatabase("tti_qap;Trusted_Connection=Yes") *


vtSql = ""
vtSql = vtSql & " SELECT tbl_inventory_ADC.col_mfr,
tbl_inventory_ADC.col_avecost "
vtSql = vtSql & " FROM " & Product.dbo.tbl_inventory_ADC
vtSql = vtSql & " WHERE (tbl_inventory_ADC.col_avecost = 0.0001)"
vtSql = vtSql & "ORDER BY (tbl_inventory_ADC.col_mfr)"

Set rs = dbs.OpenRecordset(vtSql)