C# 无法使用GridView获取所有数据

C# 无法使用GridView获取所有数据,c#,asp.net,gridview,C#,Asp.net,Gridview,我的代码有问题 以下是aspx代码: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdministratorPage.aspx.cs" Inherits="SoftwareAnalysisAndDesign.SAD.AdministratorPage" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <

我的代码有问题 以下是aspx代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdministratorPage.aspx.cs" Inherits="SoftwareAnalysisAndDesign.SAD.AdministratorPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Admin Page</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="Bootstrap/css/bootstrap-theme.css" />
    <link rel="stylesheet" href="Bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="webcss/AdministratorPageStyle.css" />
</head>
<body>
    <form id="form1" runat="server">
        <div class="headerwrapper">
            <div id="headercontent" class="jumbotron">
                <img id="img1" src="usjrlogo.png" />
                <h1 id="title">Online AppSess System</h1>
            </div>
        </div>
        <br />
        <div class="container">
            <div class="row" id="buttons">
                <div class="col-md-8">
                    <button type="button" runat="server" onserverclick="Button1_Click" id="ListofStudent" class="btn btn-primary">View Student</button>
                </div>
            </div>
            <div class="row">
                <asp:GridView runat="Server" id="data"/>
            </div>
        </div>
    </form>
</body>
</html>
当我试图从我的学生那里获取所有数据时,出现了以下错误:

MSSQLSConnector.dll中发生“System.Data.SqlClient.SqlException”类型的异常,但未在用户代码中处理 附加信息:字符串后未闭合的引号

我不知道是什么问题,但当我使用断点一步一步地检查我的程序时

它跳过了DataTable实现

dt = ds.Tables[0];

请帮助。

您的查询有一个额外的勾号,例如

"select * from student'"; <-- Here.

您的查询有一个额外的勾号,例如

"select * from student'"; <-- Here.

选择*来自学生”-这在结尾处有一个引号选择*来自学生”-这在结尾处有一个引号,没有注意到简单的错误这是正确的方法吗?从学生中选择*@laurencekeithalbano是的,你在评论中的方式。aw,没有注意到简单的错误,这是正确的方式吗?从学生中选择*@laurencekeithalbano是的,你在评论中的方式。
"select * from student'"; <-- Here.
query = "select * from student'"; //error

query = "select * from student"; //correct