Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

syntax problem with select command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mich - 15 Aug 2007 21:17 GMT
Hi,

the table 'l0382_project1' exists in sql server. I can see it.
Now in asp.net, i want to check whether it exists but i get "invalid column
name":

1st attempt:
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
[l0382_project1]"
connection.Open()
nr = comd.ExecuteScalar()

Invalid column name 'l0382_project1'.

2nd attempt:
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
['l0382_project1']"
connection.Open()
nr = comd.ExecuteScalar()

Invalid column name 'l0382_project1'.

Could somebody tell me the right syntax, please?
Thanks
Mich
Pawel Potasinski - 15 Aug 2007 21:21 GMT
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
N'l0382_project1'"

Signature

Regards
Pawel Potasinski
[http://www.potasinski.pl]

> Hi,
>
[quoted text clipped - 21 lines]
> Thanks
> Mich
Tibor Karaszi - 15 Aug 2007 21:26 GMT
The name of the table in the context of your query is just a regular string, so the query should be:

WHERE [name] = 'l0382_project1'

Signature

Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi

> Hi,
>
[quoted text clipped - 21 lines]
> Thanks
> Mich
Mich - 15 Aug 2007 21:38 GMT
Thanks for replying. It works now.

> The name of the table in the context of your query is just a regular
> string, so the query should be:
[quoted text clipped - 26 lines]
>> Thanks
>> Mich

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.