Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multi line Select Query

Hi,

I have a problem i have a select statement which is about 20 od
lines and i'm trying to retrive data from the database but the proble
is that it gives me a error. can anyone tell me how to link a multilin
select statement into one in VB.

thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Multi line Select Query

If it is more than 255 characters in length, you need to break the parts of
it into an array. Use the macro recorder to do an msquery query (Data=Get
External Data) using a similar long query string and you will see how the
array is constructed.

--
Regards,
Tom Ogilvy

"madhan " wrote in message
...
Hi,

I have a problem i have a select statement which is about 20 odd
lines and i'm trying to retrive data from the database but the problem
is that it gives me a error. can anyone tell me how to link a multiline
select statement into one in VB.

thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Multi line Select Query

A SQL statement is a single string. If it has contains line breaks
then these will be for ease of reading by a human. If you are putting
line breaks into code to make it easier to read, ensure you include
spaces between words e.g.

strSql = "SELECT Col1, Col2" & _
"FROM MyTable" ' <-error

strSql = "SELECT Col1, Col2" & _
" FROM MyTable" ' <-correct

If by multi-line you mean 20 SQL statements e.g. separated by
semicolons, you will need to send each statement one by one, but you
could do this in a batch so the RDBMS can optimize execution.

--

madhan wrote in message ...
Hi,

I have a problem i have a select statement which is about 20 odd
lines and i'm trying to retrive data from the database but the problem
is that it gives me a error. can anyone tell me how to link a multiline
select statement into one in VB.

thanks


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Multi line Select Query

Tom is correct about the break apart.
Two solutions I have found helpful...
Put sections of Query string into a Dim Qry_1, Qry_2 AS
String variable... The add/concatenate the two strings
together when building the query statement...

The second thing to do is put the concatenated String
value into a Cell comment. The you can look at it and
debug it ...





-----Original Message-----
If it is more than 255 characters in length, you need to

break the parts of
it into an array. Use the macro recorder to do an

msquery query (Data=Get
External Data) using a similar long query string and you

will see how the
array is constructed.

--
Regards,
Tom Ogilvy

"madhan " wrote

in message
...
Hi,

I have a problem i have a select statement which is

about 20 odd
lines and i'm trying to retrive data from the database

but the problem
is that it gives me a error. can anyone tell me how to

link a multiline
select statement into one in VB.

thanks


---
Message posted from
http://www.ExcelForum.com/



.

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
Is it possible to select a multi value from a drop down box Carrie Excel Discussion (Misc queries) 12 June 10th 09 08:10 PM
Concatenate: Multi-Line Cell with 2 single line cells BEEJAY Excel Worksheet Functions 0 February 15th 07 08:53 PM
how can I paste multi-line/multi-paragraph data into ONE cell? Theano Excel Discussion (Misc queries) 3 June 7th 05 01:10 PM
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM
Multi Select List Box jacqui Excel Programming 0 July 22nd 03 12:12 PM


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

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

About Us

"It's about Microsoft Excel"