首页 > 解决方案 > Visual Basic 语法错误。在页面指令中

问题描述

我遇到了“BC30035 Visual Basic 语法错误”。并且它显示在页面指令中并且看不到错误来自哪里。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginPacient.aspx.cs" Inherits="Proiect.LoginPacient" %>

这是我正在尝试使用的代码。

namespace Proiect
{
    public partial class LoginPacient
    {
        protected void Page_Load1(object sender, EventArgs e)
        {
            if (!((Page)System.Web.HttpContext.Current.CurrentHandler).IsPostBack)
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Proiect BD Connection String"].ConnectionString);
                conn.Open();
                string checkPacient = "select count(*) from Pacienti where ID_Pacient='" + userID.Text + "'";
                SqlCommand cmd1 = new SqlCommand(checkPacient, conn);
                int temp = Convert.ToInt32(cmd1.ExecuteScalar().ToString());

                if (temp == 0)
                {
                    Response.Write("Nu sunteti in baza de date. Va rugam sa va faceti cont");
                }

                conn.Close();
            }

        }
    }
}

我是 Visual Studio 的新手,但对编程并不陌生,但看不到错误来自哪里。

解决方案探索者

标签: c#asp.netsyntax-error

解决方案


最可能的问题是项目的 web.config 文件中的编译器指令引用了 VB 而不是 C#。

要解决此问题,请打开您的 web.config 并查找该<compiler指令。

找到了就换

extension = ".vb"

extension = ".cs"

type="Microsoft.VisualBasic.VBCodeProvider

type="Microsoft.CSharp.CSharpCodeProvider

推荐阅读