using System.Data;namespace WebApplication4{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string MyConnection=@"Data Source=SERVER03\SQLEXPRESS;Integrated Security=True"; SqlConnection connection=new SqlConnection(MyConnection); connection.Open(); string CmdText = "INSERT INTO DbBase(Name,Age,Sex)VALUES('"+txtName.Text+"','"+txtAge+"','"+txtSex+"')"; SqlCommand cmd = new SqlCommand(CmdText, connection); int result = cmd.ExecuteNonQuery(); Line 27: SqlCommand cmd = new SqlCommand(CmdText, connection); Line 28: Line 29: int result = cmd.ExecuteNonQuery(); Line 30: Line 31:
[SqlException (0x80131904): Invalid object name 'DbBase'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +317 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 WebApplication4._Default.btnSubmit_Click(Object sender, EventArgs e) in c:\documents and settings\administrator\my documents\visual studio 2010\Projects\WebApplication4\WebApplication4\Default.aspx.cs:29 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565