系统报错:嵌入的语句不能是声明或标记语句
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/08/23 01:12:53
系统报错:嵌入的语句不能是声明或标记语句
SqlConnection下有波浪线提示“嵌入的语句不能是声明或标记语句”
代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Vote :System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
SqlConnection conn = new SqlConnection("Data Source=7F78D182F8FA464;Initial Catalog=Vote;Persist Security Info=True;User ID=sa;Password=19821231");//建立连接对象
string strSql = "select * from Item where parentid=1";
SqlDataAdapter sda=new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds,"Item");
RadioButtonList1.DataSource=ds;
RadioButtonList1.DataTextField="ItemName";
RadioButtonList1.DataTextField="id";
RadioButtonList1.DataBind();
}
}
SqlConnection下有波浪线提示“嵌入的语句不能是声明或标记语句”
代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Vote :System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
SqlConnection conn = new SqlConnection("Data Source=7F78D182F8FA464;Initial Catalog=Vote;Persist Security Info=True;User ID=sa;Password=19821231");//建立连接对象
string strSql = "select * from Item where parentid=1";
SqlDataAdapter sda=new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds,"Item");
RadioButtonList1.DataSource=ds;
RadioButtonList1.DataTextField="ItemName";
RadioButtonList1.DataTextField="id";
RadioButtonList1.DataBind();
}
}
if(!IsPostBack)
后面一定要跟大括号,别学他们简写,这样习惯很不好!
if(!IsPostBack)
{
SqlConnection conn = new SqlConnection("Data Source=7F78D182F8FA464;Initial Catalog=Vote;Persist Security Info=True;User ID=sa;Password=19821231");//建立连接对象
string strSql = "select * from Item where parentid=1";
SqlDataAdapter sda=new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds,"Item");
RadioButtonList1.DataSource=ds;
RadioButtonList1.DataTextField="ItemName";
RadioButtonList1.DataTextField="id";
RadioButtonList1.DataBind();
}
后面一定要跟大括号,别学他们简写,这样习惯很不好!
if(!IsPostBack)
{
SqlConnection conn = new SqlConnection("Data Source=7F78D182F8FA464;Initial Catalog=Vote;Persist Security Info=True;User ID=sa;Password=19821231");//建立连接对象
string strSql = "select * from Item where parentid=1";
SqlDataAdapter sda=new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds,"Item");
RadioButtonList1.DataSource=ds;
RadioButtonList1.DataTextField="ItemName";
RadioButtonList1.DataTextField="id";
RadioButtonList1.DataBind();
}
若用Dim s(15) As Single 语句声明了数组s,以下语句中错误的是__________.
描写山水的语句,不能是诗句!
不能构成循环的语句是( ).A) for 语句 B) while 语句 C) swit
python print>>语句 报错!
声明单精度常量PI代表3.14159的语句为
下面的( )函数声明语句存在着语法错误
这么简单的语句为什么总是报错?
填入合适的词语成语或语句!必须是词语成语或语句!
(3)设有如下变量声明语句:Dim a, b As Boolean则下面叙述中正确的是
下列语句具有计算功能的是 输入语句 输出语句 赋值语句 循环语句
优美的语句,或故事!
爱情经典语句(不能是名言)