473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tough SQL Query.

My SQL string is kind of wierd one.
In my application, I need to select things from an
unknown name table. But I know the table name before the
SQL command is executed.

For instance,
Dim varname as string = 'one of my variable. It's part of
the table name.

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from t1 where
Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)


I use a string concaticate method and got error.
"Cannot find table t1".

Can some one tell me how to do that ?

Nov 20 '05 #1
28 3887
Try this:

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from " + t1 + " where Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)

I'm still new at .NET syntax, so the concats may have to occur in their own
line.
You could also do a .replace on the string.

"Arial" <Ar********@yahoo.com> wrote in message
news:2b****************************@phx.gbl...
My SQL string is kind of wierd one.
In my application, I need to select things from an
unknown name table. But I know the table name before the
SQL command is executed.

For instance,
Dim varname as string = 'one of my variable. It's part of
the table name.

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from t1 where
Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)


I use a string concaticate method and got error.
"Cannot find table t1".

Can some one tell me how to do that ?

Nov 20 '05 #2
Use the & operator for concatenating strings:

Dim t1 As String = strVarName & "0000"
Dim cmdstrAs String = "SELECT Name, Addr FROM " & t1 & " WHERE Name = ?"

Also, what does this line
cmdstr.parameters.add("Name", odbctype(char), 50) do?

The String object has no such property/method.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:eF**************@TK2MSFTNGP10.phx.gbl... Try this:

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from " + t1 + " where Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)

I'm still new at .NET syntax, so the concats may have to occur in their own line.
You could also do a .replace on the string.

"Arial" <Ar********@yahoo.com> wrote in message
news:2b****************************@phx.gbl...
My SQL string is kind of wierd one.
In my application, I need to select things from an
unknown name table. But I know the table name before the
SQL command is executed.

For instance,
Dim varname as string = 'one of my variable. It's part of
the table name.

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from t1 where
Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)


I use a string concaticate method and got error.
"Cannot find table t1".

Can some one tell me how to do that ?


Nov 20 '05 #3
Thanks! it works great!

I owe you one!
-----Original Message-----
Try this:

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from " + t1 + " where Name = ?" cmdstr.parameters.add("Name", odbctype(char), 50)

I'm still new at .NET syntax, so the concats may have to occur in their ownline.
You could also do a .replace on the string.

"Arial" <Ar********@yahoo.com> wrote in message
news:2b****************************@phx.gbl...
My SQL string is kind of wierd one.
In my application, I need to select things from an
unknown name table. But I know the table name before the SQL command is executed.

For instance,
Dim varname as string = 'one of my variable. It's part of the table name.

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from t1 where
Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)


I use a string concaticate method and got error.
"Cannot find table t1".

Can some one tell me how to do that ?

.

Nov 20 '05 #4
Hi Herfried,

It was a VB question, lol.

t1 = "TableName"
cmdstr = "Blah blah t1 blah blah"

Q: Why is cmdstr wrong?
A: Oops. I havn't learnt how to concatenate strings!!

Btw, it's the weekend again - go and have some fun. :-)

No, I mean some <different> fun! ;-D

Regards,
Fergus
Nov 20 '05 #5
You should be using & instead of +, I hope.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Arial" <ar********@yahoo.com> wrote in message
news:33****************************@phx.gbl...
Thanks! it works great!

I owe you one!
-----Original Message-----
Try this:

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from " + t1

+ " where Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)

I'm still new at .NET syntax, so the concats may have to

occur in their own
line.
You could also do a .replace on the string.

"Arial" <Ar********@yahoo.com> wrote in message
news:2b****************************@phx.gbl...
My SQL string is kind of wierd one.
In my application, I need to select things from an
unknown name table. But I know the table name before the SQL command is executed.

For instance,
Dim varname as string = 'one of my variable. It's part of the table name.

Dim t1 as String = varname+ "0000"
Dim cmdstr as string ="Select Name, Addr from t1 where
Name = ?"
cmdstr.parameters.add("Name", odbctype(char), 50)


I use a string concaticate method and got error.
"Cannot find table t1".

Can some one tell me how to do that ?

.

Nov 20 '05 #6
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
It was a VB question, lol.

t1 = "TableName"
cmdstr = "Blah blah t1 blah blah"

Q: Why is cmdstr wrong?
A: Oops. I havn't learnt how to concatenate strings!!

Btw, it's the weekend again - go and have some fun. :-)

No, I mean some <different> fun! ;-D


Today (yesterday) I was on "Mac Styria Tour" with some friends. We visited
all 20 McDonals's restaurants in our district (Styria).

;-)))

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #7
Hello,

"Tom Spink" <th**********@ntlworld.com> schrieb:
You should be using & instead of +, I hope.


Mega-LOL.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #8
Hi Herfried,

ROFL.

Und jetzt sind Sie gebloaten, ja?

Regards,
Fergus
Nov 20 '05 #9
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
ROFL.

Und jetzt sind Sie gebloaten, ja?


What do you mean by "gebloaten"?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #10
Hi Herfried,

My apologies, I thought I'd already talked about it here, but I did a search and nothing came up. Now I remember it was in a
totally different forum!!

As I mentioned, I don't know German, but love the sound of it. So sometimes in my pretend German I make up words using an
English root and German prefixes and suffixes.

Wenn Sie "gebloaten" sind, es ist nicht <voll> und es ist nicht <sehr voll>. Nein, es ist "ooooooh, Ich habe viel zu viel
gegessen." voll. :-)

From the English "bloated" - which I imagine after 20 Big Macs, you would have been, lol.
From another (unsent) reply:
|| > No, I mean some <different> fun! ;-D
||
|| We visited all 20 McDonalds's restaurants

That's certainly different. :-)

What was the purpose? Did you eat at each one, like in a pub crawl?

Regards,
Fergus
Nov 20 '05 #11
And this has relevance to a 'Tough SQl Query'?

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Herfried,

My apologies, I thought I'd already talked about it here, but I did a search and nothing came up. Now I remember it was in a totally different forum!!

As I mentioned, I don't know German, but love the sound of it. So sometimes in my pretend German I make up words using an English root and German prefixes and suffixes.

Wenn Sie "gebloaten" sind, es ist nicht <voll> und es ist nicht <sehr voll>. Nein, es ist "ooooooh, Ich habe viel zu viel gegessen." voll. :-)

From the English "bloated" - which I imagine after 20 Big Macs, you would have been, lol.

From another (unsent) reply:
|| > No, I mean some <different> fun! ;-D
||
|| We visited all 20 McDonalds's restaurants

That's certainly different. :-)

What was the purpose? Did you eat at each one, like in a pub crawl?

Regards,
Fergus

Nov 20 '05 #12
Obviously not. Does it need to have?
Nov 20 '05 #13
Seeing as this is a newsgroup about the VB.Net language and the thread is
about 'Tough SQL Query' then Yes.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
Obviously not. Does it need to have?

Nov 20 '05 #14
Why?
Nov 20 '05 #15
|| Seeing as this is a newsgroup about the
|| VB.Net language and the thread is
|| about 'Tough SQL Query'

Insufficient reason.
Nov 20 '05 #16
Cor
Stephany,
Yes this is a newsgroup about a language,
And the people who often contribute in this newsgroup, did add somethimes
extra to this newsgroup.
This gives a better idea why they are writting something in a certain way
and that makes the discussion richer and better understandable for the ones
who contributes a lot.

You can see that too in the discussion about for next and do while.
A Spanish writter tells to an Austrian writter that he should not use those
difficult Englisch words.
After some chat they understand each other.

Herfried, was quick answering messages yesterday.
Now we know he was bloated and could not reach his keyboard with his arms.

Cor
Nov 20 '05 #17
"Stephany Young" <st******@sysoft.co.nz> schrieb
And this has relevance to a 'Tough SQl Query'?


They love this kind of discussions. It has it's advantages: After receiving
100 new posts, you can mark 90 of them as "read". ;-))))

--
Armin

Nov 20 '05 #18
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
As I mentioned, I don't know German,
You know a lot of German...
but love the sound of it. So sometimes in my pretend German
I make up words using an English root and German prefixes and
suffixes.
:-)
Wenn Sie "gebloaten" sind, es ist nicht <voll> und es ist nicht
<sehr voll>. Nein, es ist "ooooooh, Ich habe viel zu viel
gegessen." voll. :-)
Now I understand what you mean.
From the English "bloated" - which I imagine after 20 Big Macs, you
would have been, lol.
I didn't eat 20 Big Macs.
From another (unsent) reply:
|| > No, I mean some <different> fun! ;-D
||
|| We visited all 20 McDonalds's restaurants

That's certainly different. :-)

What was the purpose? Did you eat at each one, like in a pub
crawl?


Yes. It doesn't make sense at all, but I meet some good friends.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #19
Hello,

"Stephany Young" <st******@sysoft.co.nz> schrieb:
And this has relevance to a 'Tough SQl Query'?


No, sorry!

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #20
Hello,

"Cor" <no*@non.com> schrieb:
Yes this is a newsgroup about a language,
And the people who often contribute in this newsgroup, did
add somethimes extra to this newsgroup.
I add OT postings too often, I know.
You can see that too in the discussion about for next and do while.
A Spanish writter tells to an Austrian writter that he should not use
those difficult Englisch words.
After some chat they understand each other.
:-)
Herfried, was quick answering messages yesterday.
Now we know he was bloated and could not reach his keyboard
with his arms.


LOL.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #21
> I didn't eat 20 Big Macs.

Was it one chip per McDonalds?

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
As I mentioned, I don't know German,


You know a lot of German...
but love the sound of it. So sometimes in my pretend German
I make up words using an English root and German prefixes and
suffixes.


:-)
Wenn Sie "gebloaten" sind, es ist nicht <voll> und es ist nicht
<sehr voll>. Nein, es ist "ooooooh, Ich habe viel zu viel
gegessen." voll. :-)


Now I understand what you mean.
From the English "bloated" - which I imagine after 20 Big Macs, you
would have been, lol.


I didn't eat 20 Big Macs.
From another (unsent) reply:
|| > No, I mean some <different> fun! ;-D
||
|| We visited all 20 McDonalds's restaurants

That's certainly different. :-)

What was the purpose? Did you eat at each one, like in a pub
crawl?


Yes. It doesn't make sense at all, but I meet some good friends.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #22
Hi Cor,

|| Herfried, was quick answering messages yesterday.
|| Now we know he was bloated and could not reach
|| his keyboard with his arms

ROFLMAO

Cheers,
Fergus
Nov 20 '05 #23
Hi Herfried,

|| "Stephany Young" <st******@sysoft.co.nz> schrieb:
|| > And this has relevance to a 'Tough SQl Query'?
||
|| No, sorry!

Don't be a wimp. It's not good for you.

It also contradicts other statements that you have made regarding OT.

This makes you look as if you're ready to leap left or right whenever
someone demands.

Regards,
Fergus

ps. I don't want an apology about your apology, either. Sit up straight, stick
your chest out and hold your head high!

;-)
Nov 20 '05 #24
Hi Herfried,

|| You know a lot of German...

Sort of.
This helps: http://www.freetranslation.com/

|| I didn't eat 20 Big Macs.

I'm glad of that!! :-)

|| Yes. It doesn't make sense at all, but I meet some good friends.

It makes (almost) perfect sense - you met up with some good friends. :-D

I did a bit of a lookup on Austria. Total population less than the
residential population of London - let alone the working population. Ah, the
freedom, the space!!

Regards,
Fergus
Nov 20 '05 #25
Which of course is where we get

Mein Hovercraft ist voll von Aalen

Charles
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi Herfried,

|| You know a lot of German...

Sort of.
This helps: http://www.freetranslation.com/

|| I didn't eat 20 Big Macs.

I'm glad of that!! :-)

|| Yes. It doesn't make sense at all, but I meet some good friends.

It makes (almost) perfect sense - you met up with some good friends. :-D
I did a bit of a lookup on Austria. Total population less than the
residential population of London - let alone the working population. Ah, the freedom, the space!!

Regards,
Fergus

Nov 20 '05 #26
Hi Charles,

|| Mein Hovercraft ist voll von Aalen

My hovercraft is full of eels ??

I know that eels are a particular delicacy in Aalen, Austria*, but where
does the hovercraft bit come from?

Regards,
Fergus

* Believe that, you'll believe anything. :-)
Nov 20 '05 #27
Ah, c'est Monsieur le Python. From the book with dirty fingerprints.

Charles
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
Hi Charles,

|| Mein Hovercraft ist voll von Aalen

My hovercraft is full of eels ??

I know that eels are a particular delicacy in Aalen, Austria*, but where does the hovercraft bit come from?

Regards,
Fergus

* Believe that, you'll believe anything. :-)

Nov 20 '05 #28
Hi Charles,

Ah. Yes. Nick (Nak) and I have been into the Monty bit. I never got it the
first time round so I remain much in ignorance to this day. But now that I
know you're a Montyite I shall be on the lookout for things that make me go
"duh?? ".

;-)

Regards,
Fergus
Nov 20 '05 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: leegold2 | last post by:
Let's I do a mysql query and then I do a, for( $i = 1; $row = mysql_fetch_array($result); $i++ ) {...} and it gives me this: PageID Title URL Description 1 lee's ...
3
by: Roman | last post by:
I've been trying this one for 2-3 hours and can't figure it out. I'de appreciate any help or pointers in the right direction. Thanks. Query I need the query to return me all the lottery names...
198
by: Sy Borg | last post by:
Hello: We are designing two multi-user client server applications that performs large number of transactions on database servers. On an average Application A has a 50% mix of select and...
2
by: greg | last post by:
Hi Basically I call a page that does a very long op (like very long database query) and display results (possible on another page) But I need to display a progress bar for user to see some...
12
by: Bill Bob | last post by:
I am going mad with this Query. I need to join 3 Tables. Their Formats are Vouchers NOT NULL , NOT NULL , NULL , NOT NULL , (255) CONSTRAINT PRIMARY KEY CLUSTERED
7
by: Dan | last post by:
I am trying to create a query (in either sql or the design view) to determine which two (or more I suppose if it's not too complicated) baseball players were teammates the longest. The database...
9
by: DFS | last post by:
The following data set is building inspection visits. It consists of multiple visits (2+) made to the same building on the same day. I want to get a list of visits made to the same building on...
5
by: steven.fafel | last post by:
I am running 2 versions of a correlated subquery. The two version differ slightly in design but differ tremendously in performance....if anyone can answer this, you would be awesome. The "bad"...
5
by: jconstan | last post by:
hey all, i am having a problem with a certain query which pulls records from two tables. one table contains info entered into a main form, and the other has information entered into the subform. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.