c# - 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 的新手,但对编程并不陌生,但看不到错误来自哪里。
解决方案
最可能的问题是项目的 web.config 文件中的编译器指令引用了 VB 而不是 C#。
要解决此问题,请打开您的 web.config 并查找该<compiler
指令。
找到了就换
extension = ".vb"
至
extension = ".cs"
和
type="Microsoft.VisualBasic.VBCodeProvider
至
type="Microsoft.CSharp.CSharpCodeProvider
推荐阅读
- clojure - 在累积所有违规行为的同时在 Clojure 中进行多项检查的最佳方法
- r - R:列出所有无方向的圆形排列/排列(即顺时针/逆时针相同)
- tensorflow - 如何在 MultiOutput LSTM Tensorflow 中优先考虑某些输出?
- flutter - 为什么我们需要在声明变量时添加late修饰符?
- reactjs - React-Select 在选择一个值时下拉选项变为零
- python - 使用更大运算符在两个列表之间进行 Python 比较
- nginx - Yii2 Nginx Elastic Beanstalk 上的高级模板
- java - 如何设置和保存日期对象
- c++ - Gdiplus::屏幕上的图像 (C++)
- python - 在 Power BI 中设置 API 以从网站提取数据