|
|
|
start date: Wed, 15 Aug 2007 22:17:15 +0200,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Mich
|
|
2
Pawel Potasinski
|
|
3
Tibor Karaszi
|
|
4
Mich
|
syntax problem with select command
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
Date:Wed, 15 Aug 2007 22:17:15 +0200
Author:
|
Re: syntax problem with select command
comd.CommandText = "SELECT COUNT(*) FROM sys.tables WHERE [name] =
N'l0382_project1'"
--
Regards
Pawel Potasinski
[http://www.potasinski.pl]
Uytkownik "Mich" napisa w wiadomoci
news:uOe%23Gl33HHA.5796@TK2MSFTNGP05.phx.gbl...
> 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
>
Date:Wed, 15 Aug 2007 22:21:37 +0200
Author:
|
Re: syntax problem with select command
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'
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Mich" wrote in message news:uOe%23Gl33HHA.5796@TK2MSFTNGP05.phx.gbl...
> 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
>
>
Date:Wed, 15 Aug 2007 22:26:03 +0200
Author:
|
Re: syntax problem with select command
Thanks for replying. It works now.
"Tibor Karaszi" schreef
in bericht news:uZQXCq33HHA.1164@TK2MSFTNGP02.phx.gbl...
> 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'
>
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
>
> "Mich" wrote in message
> news:uOe%23Gl33HHA.5796@TK2MSFTNGP05.phx.gbl...
>> 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
Date:Wed, 15 Aug 2007 22:38:41 +0200
Author:
|
|
|