问题描述
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.SqlClient;publicpartialclassideas:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(PreviousPage!=null){if(PreviousPage.IsCrossPagePostBack)stringusername=(((TextBox)PreviousPage.FindControl("username"))).Text;stringpassword=(((TextBox)PreviousPage.FindControl("password"))).Text;stringsex=(((TextBox)PreviousPage.FindControl("sex"))).Text;stringage=(((TextBox)PreviousPage.FindControl("age"))).Text;stringbirth=(((TextBox)PreviousPage.FindControl("birth"))).Text;stringemail=(((TextBox)PreviousPage.FindControl("email"))).Text;stringqq=(((TextBox)PreviousPage.FindControl("qq"))).Text;stringaddress=(((TextBox)PreviousPage.FindControl("address"))).Text;stringconnectionstring="datasource=.;Initialcatalog=用户注册信息;IntegratedSecurity=true;";using(sqlconnectionconn=newSqlConnection(connectionstring)){stringsqlstr="Insertintozhuce(username,password,sex,age,birth,email,qq,address)values(@username,@password,@sex,@age,@birth,@email,@qq,@address)";SqlCommandcomm=newSqlCommand(sqlstr,conn);comm.Parameters.AddWithValue("@username",username);comm.Parameters.AddWithValue("@password",password);comm.Parameters.AddWithValue("@sex",sex);comm.Parameters.AddWithValue("@age",age);comm.Parameters.AddWithValue("@birth",birth);comm.Parameters.AddWithValue("@email",email);comm.Parameters.AddWithValue("@qq",qq);comm.Parameters.AddWithValue("@address",address);conn.Open();comm.EndExecuteNonQuery();Response.Write("<script>alert("注册成功")</script>");}}}}遇到问题是:嵌入的语句不能是声明或标志语句,请各位高手指教...
解决方案
解决方案二:
觉得你connectionstring写的有问题
解决方案三:
觉得你connectionstring写的有问题
解决方案四:
该回复于2011-12-01 09:13:13被版主删除
解决方案五:
是不是connectionstring应该是staticstring啊?你试试看
解决方案六:
我找出问题了,是我的sql数据库服务器名有问题