It is currently 09 Sep 2010, 13:32

All times are UTC + 2 hours





 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: Connect to SQL2005 DB from excel VBA
PostPosted: 30 Jul 2010, 08:36 
Registered User

Joined: 09 Apr 2010, 15:18
Posts: 172
Ive got the following code which works.

MyQuery = "INSERT INTO FC_VALUES (ITEM_NUMBER,ITEM_DESC) VALUES ('EXCELTESTNUMBER','TEST DESCRIPTION')"
'MsgBox MyQuery

Sheets("Sheet1").Select
Range("A1").Select
Sqlstring = MyQuery '"select IDCUST from ARCUS"

connstring = "ODBC;DSN=ODBCTEST;UID=sa;PWD=password01#;Database=FC_DB"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=Sqlstring)

.Refresh
End With


Problem is the above puts some text in to A1 which i dont want.
If i had to run the query twice its shifts A1 to A2 and put some text into A1 "Excel Query" or something like that.
I want to run a SQL query without it putting text on the sheet.

How can i do that?
I even tried to put the code in Sheet1 then Say Sheet2.A1



_________________
_̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡
Offline
 Profile E-mail  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 1 post ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to: