Re: Incorrect Syntax Near (table name). why ??
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 8 Mar 2007 18:49:09 -0500
roger_27 wrote:
public static DataSet LoadAllUserInfo()
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic ADO newsgroup. ADO.Net bears
very little resemblance to classic ADO so, while you may be lucky enough to
find a dotnet-knowledgeable person here who can answer your question, you
can eliminate the luck factor by posting your question to a group where
those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.adonet.
Hoiwever, the answer will probably be the same as the one you would get if
you wer using classic ASP, so read on.
{
//constring defined earlier
SqlCon = new SqlConnection(ConString);
//problem sql statement here**
string SqlStat = @"SELECT * FROM User";
DataSet UserData = new DataSet();
SqlDataAdapter DataAdapt = new SqlDataAdapter(SqlStat, SqlCon);
SqlCon.Open();
DataAdapt.Fill(UserData);
SqlCon.Close();
return UserData;
}
there is my code. I havent used sql in a long time, but whats wrong
here? I tried putting a semicolon at the end of the statement and it
still didnt work. whats wrong with my statement ?
I'm pretty sure "User" is a reserved keyword ... yes, I found it in this
list:
http://www.aspfaq.com/show.asp?id=2080
Your best course of action would be to change the name of the table, but if,
for some reason, you are unable to do so, you will need to remember to
surround it with brackets [] when using it in queries run via ADO and
ADO.Net.
Additionally, this advice still applies in ADO.Net:
http://www.aspfaq.com/show.asp?id=2096
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- Re: Incorrect Syntax Near (table name). why ??
- From: roger_27
- Re: Incorrect Syntax Near (table name). why ??
- Prev by Date: Re: C++ support for ADO
- Next by Date: Re: Incorrect Syntax Near (table name). why ??
- Previous by thread: Re: how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding?
- Next by thread: Re: Incorrect Syntax Near (table name). why ??
- Index(es):
Relevant Pages
|
|