为什么在我的c#页面中出现此异常错误 [英] why is this exception error in my c# page

查看:96
本文介绍了为什么在我的c#页面中出现此异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=true;Initial Catalog=myproject");
        SqlCommand cmd = new SqlCommand("Select * from room where roomstatus like occupied'",con);
        con.Open();
     
        GridView1.DataSource =cmd.ExecuteReader();
        GridView1.DataBind();
        con.Close();

    }









错误:字符串''





Error : Unclosed quotation mark after the character string ''

推荐答案

之后的未闭合引号尝试:

Try:
SqlCommand cmd = new SqlCommand("Select * from room where roomstatus like 'occupied'",con);



您忘了单引号。


You forgot a single quote.


SqlCommand cmd = new SqlCommand("Select * from room where roomstatus like occupied'",con);







occupied'"





占用后删除这个额外的单引号



after occupied remove this extra single quote


这篇关于为什么在我的c#页面中出现此异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆