这是源代码:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void submit_Click(object sender, EventArgs e)
{
string name = this.txtusn.Text.Trim();
string pass = this.txtpsw.Text.Trim(); string realName = this.txtname.Text.Trim();
string sex = "";
if (RadioBtn1.Checked)
{
sex = "男"; }
else sex = "女";
string qq = this.txtQQ.Text.Trim();
string tel = this.txttel.Text.Trim();
string email = this.txte.Text.Trim();
SqlConnection conn = new DBConn().getConnection();
string mySQL = "insert into Users(u_Name,u_Pass,u_Realname,u_Sex,u_QQ,u_Tel,u_Email) values('";
mySQL += name + "','" + pass + "','" + realName + "','" + sex + "','" + qq + "','" + tel + "','" + email + "')"; SqlDataAdapter sda = new SqlDataAdapter(mySQL, conn);
DataSet ds = new DataSet();
sda.Fill(ds); }
}
这是错误提示提示在最后一句 sda.fill(ds)
用户代码未处理 System.Data.SqlClient.SqlException
Message="在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=2
Server=""
State=0
StackTrace:
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.SqlClient.SqlConnection.Open()
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
在 login1.submit_Click(Object sender, EventArgs e) 位置 e:\mylyb\login1.aspx.cs:行号 46
在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void submit_Click(object sender, EventArgs e)
{
string name = this.txtusn.Text.Trim();
string pass = this.txtpsw.Text.Trim(); string realName = this.txtname.Text.Trim();
string sex = "";
if (RadioBtn1.Checked)
{
sex = "男"; }
else sex = "女";
string qq = this.txtQQ.Text.Trim();
string tel = this.txttel.Text.Trim();
string email = this.txte.Text.Trim();
SqlConnection conn = new DBConn().getConnection();
string mySQL = "insert into Users(u_Name,u_Pass,u_Realname,u_Sex,u_QQ,u_Tel,u_Email) values('";
mySQL += name + "','" + pass + "','" + realName + "','" + sex + "','" + qq + "','" + tel + "','" + email + "')"; SqlDataAdapter sda = new SqlDataAdapter(mySQL, conn);
DataSet ds = new DataSet();
sda.Fill(ds); }
}
这是错误提示提示在最后一句 sda.fill(ds)
用户代码未处理 System.Data.SqlClient.SqlException
Message="在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=2
Server=""
State=0
StackTrace:
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.SqlClient.SqlConnection.Open()
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
在 login1.submit_Click(Object sender, EventArgs e) 位置 e:\mylyb\login1.aspx.cs:行号 46
在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
解决方案 »
- 字符串存入sqlserver............................................................新手在线求解
- 求教 ASP.net页面访问权限 的问题
- 有高人做过只有服务器端的网络游戏吗?(用asp.net),介绍下经验(小分送上)
- 自定义控件属性设置问题
- 帮个忙现在急用!!!!!!
- 救命!在线等.我把做好的asp.net应用程序移动到另一台的服务器上后无法正常运行.
- 急! 鼠标滑过显示数据库详细信息在.cs页面如何编写程序
- 控件被其他控件覆盖
- 如何在JAVASCRIPT中对DATAGRID的CHECKBOX列赋值?能实现吗?
- 怎样使鼠标移动到一个按钮上时就产生一个事件?
- WCF中服务的操作能同时支持GET和POST吗
- 一个奇怪的问题,不看不知道啊。
http://blog.csdn.net/zhangyang0402/archive/2007/05/07/1598646.aspx
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;/// <summary>
///DBConn 的摘要说明
/// </summary>
public class DBConn
{
public DBConn()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public SqlConnection getConnection()
{
return new SqlConnection("server=.;database=Messages;uid=sa;pwd=sa123456");
}
}