【发布时间】:2018-12-23 16:12:25
【问题描述】:
我遇到了“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 新手,但对编程并不陌生,但看不出错误来自哪里。
【问题讨论】:
-
你想在 VB.Net 项目中使用 c# 吗?
-
您永远不应该在用户直接输入的情况下执行 SQL。您的代码易受 SQL 注入攻击。当您更习惯于编程时,考虑转向参数化查询。
-
@Crowcoder 这是一个网络表单,所以我猜是这样
-
@bradbury9 谢谢!这只是一个我正在努力解决的学校项目
-
您能否展示一下您的解决方案资源管理器的屏幕截图?
标签: c# asp.net syntax-error