初学提问 按照书本敲 也显示了错误
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS1518: 应输入 class、delegate、enum、interface 或 struct
源错误:
行 17: }
行 18: }
行 19: protected void btnValidate_Click(Object sender,EventArgs e)
行 20: {
行 21: int i=userNameValidate();
源文件: e:\My Documents\Visual Studio 2005\WebSites\WebSite1\Register.aspx.cs 行: 19
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;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { }}protected void btnValidate_Click(Object sender,EventArgs e){int i=userNameValidate();}///<summary>///验证用户是否存在///</summary>public int userNameValidate(){sqlConnection conn=new sqlConnextion(ConfigurationManager.Appsettings["DBConnectionString"]);SqlCommand selecCmd =new SqlCommand("select * from Users where userId='"+txtName.Text.Trim()+"'",conn);int i=0;try{conn.open();SqlDataReader sdr = SelectCmd.ExecuteReader();if (sdr.Read()){int i=1;lblMessage.Text="此用户已存在,请输入其他用户名";}else{lblMessage.Text="此用户名是可用的!";}}catch(System.exception ee){Response.write("<script language=javascript>alert('"+ee.Message.toString+"')</script>");}finally{conn.Close;}}