LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Query SQL Server with concatenated text from Excel

Hi,

I've found a module that will let me query SQL Server databases via
ODBC. Below I've created a module which does exactly what I want it to
do using concatenated cells in a worksheet. My issue however, is that
now that I've gotten the code correct, excel tells me it doesn't have
the resources necessary to execute the command. My example below
searches for 2 UPCs, in reality I'll have several hundred, possibly
thousands. If I type these values in manually they work just fine, and
I've even tried executing the code on the SQL server itself with no
luck. Is there a more efficient way to do this? I can't simply query
everything then do a lookup table because the results exceed excels
max dimensions. I'm essentially trying to see if these UPCs are in our
system.

Thanks!

<----begin code------

Sub what()

Dim qt As QueryTable

sqlstring = "select vm.vendor, im.upc_ean, im.description,
vi.vendor_item, vi.case_pack from vendor_item vi, vendor_master vm,
item_master im where vi.record_status < 3 and vm.record_status<3 and
im.record_status<3 and vi.item_id = im.item_id and vi.v_id =vm.v_id
and vi.vi_block_from_pos=0 and vendor='" & Sheet3.Range("A1") & "' and
upc_ean like '" & Sheet3.Range("A3") & ""

connstring = _
"ODBC;DSN=tciinstore;UID=administrator;PWD=!
password;Database=tciinstore"

With Sheet1.QueryTables.Add(Connection:=connstring,
Destination:=Range("A1"), Sql:=sqlstring)
.Refresh
End With

Sheet1.Range("A1").Select
End Sub


<----end code------
 
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
Excel with SQL Query (*.sql) and SQL Server Kode Excel Discussion (Misc queries) 2 May 8th 07 01:10 PM
Excel:Get concatenated text to be recognised as formula not text? yvette Excel Discussion (Misc queries) 5 January 15th 07 07:32 PM
Query SQL Server from Excel Doctorjones_md Excel Worksheet Functions 1 January 6th 07 08:35 AM
Query SQL Server from Excel Doctorjones_md Excel Programming 1 January 6th 07 08:35 AM
How do I convert a text array to a concatenated text cell? Excel. Vargasjc Excel Worksheet Functions 5 December 20th 06 06:35 PM


All times are GMT +1. The time now is 08:55 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"