首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

System.Data.SqlClient.SqlException: 第 1 行: ',' 附近有语法异常

2012-01-30 
System.Data.SqlClient.SqlException: 第 1 行: , 附近有语法错误“/AJAXEnabledWebSite2”应用程序中的服

System.Data.SqlClient.SqlException: 第 1 行: ',' 附近有语法错误
“/AJAXEnabledWebSite2”应用程序中的服务器错误。
--------------------------------------------

第   1   行:   ', '   附近有语法错误。  
说明:   执行当前   Web   请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  

异常详细信息:   System.Data.SqlClient.SqlException:   第   1   行:   ', '   附近有语法错误。

源错误:  

执行当前   Web   请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。    

堆栈跟踪:  


[SqlException   (0x80131904):   第   1   行:   ', '   附近有语法错误。]
      System.Data.SqlClient.SqlConnection.OnError(SqlException   exception,   Boolean   breakConnection)   +177
      System.Data.SqlClient.SqlInternalConnection.OnError(SqlException   exception,   Boolean   breakConnection)   +68
      System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject   stateObj)   +199
      System.Data.SqlClient.TdsParser.Run(RunBehavior   runBehavior,   SqlCommand   cmdHandler,   SqlDataReader   dataStream,   BulkCopySimpleResultSet   bulkCopyHandler,   TdsParserStateObject   stateObj)   +2411
      System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader   ds,   RunBehavior   runBehavior,   String   resetOptionsString)   +147
      System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior   cmdBehavior,   RunBehavior   runBehavior,   Boolean   returnStream,   Boolean   async)   +1038
      System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior   cmdBehavior,   RunBehavior   runBehavior,   Boolean   returnStream,   String   method,   DbAsyncResult   result)   +314
      System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult   result,   String   methodName,   Boolean   sendToPipe)   +413
      System.Data.SqlClient.SqlCommand.ExecuteNonQuery()   +115
      System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand   command,   DataSourceOperation   operation)   +392
      System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary   keys,   IDictionary   oldValues)   +642
      System.Web.UI.DataSourceView.Delete(IDictionary   keys,   IDictionary   oldValues,   DataSourceViewOperationCallback   callback)   +71
      System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow   row,   Int32   rowIndex)   +928
      System.Web.UI.WebControls.GridView.HandleEvent(EventArgs   e,   Boolean   causesValidation,   String   validationGroup)   +1152
      System.Web.UI.WebControls.GridView.RaisePostBackEvent(String   eventArgument)   +190
      System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String   eventArgument)   +7
      System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler   sourceControl,   String   eventArgument)   +11
      System.Web.UI.Page.RaisePostBackEvent(NameValueCollection   postData)   +170
      System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint,   Boolean   includeStagesAfterAsyncPoint)   +4921



 


--------------------------------------------
版本信息:   Microsoft   .NET   Framework   版本:2.0.50727.832;   ASP.NET   版本:2.0.50727.832  
希望大家帮忙说说什么问题:


代码如下:

<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "Default.aspx.cs "   Inherits= "_Default "     Debug= "true "%>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.1//EN "   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head   runat= "server ">
        <title> Untitled   Page </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
                &nbsp; <div   style= "text-align:   center ">
                        <asp:GridView   ID= "GridView1 "   runat= "server "   AutoGenerateColumns= "False "   DataSourceID= "SqlDataSource1 "
                                Width= "735px "   AutoGenerateDeleteButton= "True "   AutoGenerateEditButton= "True "   Height= "200px ">
                                <Columns>
                                        <asp:BoundField   DataField= "TrueName "   HeaderText= "TrueName "   SortExpression= "TrueName "   />
                                        <asp:BoundField   DataField= "Tk_topic "   HeaderText= "Tk_topic "   SortExpression= "Tk_topic "   />
                                        <asp:BoundField   DataField= "Tk_addtime "   HeaderText= "Tk_addtime "   SortExpression= "Tk_addtime "   />
                                        <asp:BoundField   DataField= "Tk_done "   HeaderText= "Tk_done "   SortExpression= "Tk_done "   />
                                        <asp:BoundField   DataField= "Gp_name "   HeaderText= "Gp_name "   SortExpression= "Gp_name "   />
                                </Columns>
                        </asp:GridView>
                        <asp:SqlDataSource   ID= "SqlDataSource1 "   runat= "server "   ConnectionString= " <%$   ConnectionStrings:xzptConnectionString   %> "


                                  SelectCommand= "select   TrueName   ,   Tk_topic   ,   Tk_addtime   ,   Tk_done   ,   Gp_name     From   Users   ,GroupInfo   ,   TaskInfo     Where   Users.UserName=@UserName   AND   Users.Gp_ID   =   GroupInfo.Gp_ID     AND     Users.Gp_ID   =   TaskInfo.Gp_ID     AND     Users.Tm_ID=   TaskInfo.Tm_ID   order   by   Tk_addtime     desc "
                                  DeleteCommand= "delete   from   TaskInfo   ,Users   ,GroupInfo   where   Users.UserName=@UserName   AND   Users.Gp_ID   =   GroupInfo.Gp_ID     AND     Users.Gp_ID   =   TaskInfo.Gp_ID     AND     Users.Tm_ID=   TaskInfo.Tm_ID "    
                                  UpdateCommand= " "
                                >
                                <SelectParameters>
                                        <asp:SessionParameter   Name= "UserName "   SessionField= "UserName "   />
                                </SelectParameters>
                                <DeleteParameters>
                                      <asp:SessionParameter   Name= "UserName "     SessionField= "UserName "   />
                                </DeleteParameters>
                        </asp:SqlDataSource>
                        &nbsp; </div>
        </form>
</body>
</html>

感激了   !

[解决办法]
Sql语句写错了


[解决办法]
把SQL语句拿到查询分析器里一试就知道了。
[解决办法]
delete from TaskInfo ,Users ,GroupInfo where Users.UserName=@UserName AND Users.Gp_ID = GroupInfo.Gp_ID AND Users.Gp_ID = TaskInfo.Gp_ID AND Users.Tm_ID= TaskInfo.Tm_ID


弱弱的问下:有这样的删除语句吗???????
[解决办法]
DeleteCommand这个问题
看看Delete的语句是怎么写的
[解决办法]
楼主可以参考下这个语句:
DELETE titleauthor
FROM titleauthor
INNER JOIN titles
ON titleauthor.title_id = titles.title_id


WHERE titles.title LIKE '%computers% '
[解决办法]
select TrueName , Tk_topic , Tk_addtime , Tk_done , Gp_name From Users ,GroupInfo , TaskInfo Where Users.UserName=@UserName AND Users.Gp_ID

这里Tk_done , Gp_name From Users ,是不是掉了个,?应该是Tk_done , Gp_name , From Users ,吧?
[解决办法]
您的SQL语句的语法错误`楼主自己仔细看下吧

热点排行