双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

查找 标记时遇到意外的文件结尾 怎么回事?

mengfly mengfly 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
源代码:

<% @ page language="c#" %>
<% @ Import namespace="System.Data" %>
<% @ Import namespace="System.Data.SqlClient" %>
<!-- #include virtual="/samples/common_function.inc" -->
<script language="c#" runat="server">
private void Page_Load(object Src,EventArgs E)
{
try{
if(!IsPostBack)
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}

private void Add_Click(object sender,EventArgs E)
{
try{
string insertCmd="insert into dept values (@dept_id,@dept_name)";
string strconn="server=localhost;uid=sa;password=;database=edu";
SqlConnection myConnection=new SqlConnection(strconn);
SqlCommand myCommand=new SqlCommand(insertCmd,myConnection);
myCommand.Parameters.Add(new SqlParameter("@dept_id",SqlDbType.VarChar,50));
myCommand.Parameters["@dept_id"].Value=dept_id.Value;
myCommand.Parameters.Add(new SqlParameter("@dept_name",SqlDbType.VarChar,50));
myCommand.Parameters["@dept_name"].Value=dept_name.Value;
myConnection.Open();

try{
myCommand.ExecuteNonQuery();
MessageSQLInsDone();
}
catch(System.Data.SqlClient.SqlException e){
SQLErrorHandler(e);
}
myConnection.Close();
BindGrid();
}
catch(System.Exception e){
ErrorHandler(e.ToString());
}
}

private void BindGrid()
{
try{
string strconn="server=localhost;uid=sa;password=;database=edu";
SqlConnection myConnection=new SqlConnection(strconn);
SqlDataAdapter myCommand=new SqlDataAdapter("select dept_id,dept_name from dept",myConnection);
DataSet ds=new DataSet();
myCommand.Fill(ds,"dept");
mydatagrid.DataSource=ds.Tables["dept"].DefaultView;
mydatagrid.DataBind();
}
catch(System.Exception e)
{
Message.Style["color"]="red";
Message.InnerHtml="error:"+e.ToString();
}
}

</script>
有谁能指教一下 谢谢!
...全文
评论 7
收藏 已收藏
分享
返回顶部
mengfly
.NET社区 62,274 成员 668,968 内容