PDA

View Full Version : خطا در نمایش سایت



*shidrokh*
سه شنبه 01 مرداد 1392, 18:40 عصر
میشه بگین چطوری این خطا رو رفع کنم؟
کجا باید دنبالش بگردم؟
Object reference not set to an instance of an object.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] _Default.B_Login_Click(Object sender, EventArgs e) +99 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

javad13
سه شنبه 01 مرداد 1392, 21:24 عصر
سلام
کد مربوط به همین صفحه رو بزار تا بهت بگم.

مشخصه که یکی از اشیایی که استفاده کردی رو مقدار ندادی

*shidrokh*
سه شنبه 01 مرداد 1392, 22:56 عصر
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void B_Login_Click(object sender, EventArgs e)
{

SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
string cs = ConfigurationManager.ConnectionStrings["connection"].ConnectionString.ToString();
con.ConnectionString = cs;
con.Open();

string sql = "select t1.*,t2.roleName as roleName from tbl_personel as t1 inner join tbl_roleType as t2 on t1.pRoleId_fk = t2.roleId where pUser=N'{0}' and pPass=N'{1}' and pstatus=N'{2}'";
sql = string.Format(sql, T_UserName.Text, T_Pass.Text,'1');
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();

da.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
Session["PersonelNumber"] = dt.Rows[0]["pId"].ToString();
Session["UserName"] = dt.Rows[0]["pUser"].ToString();
if (dt.Rows[0]["roleName"].ToString() == "مدیر")
{
Response.Redirect("A-Default.aspx");
}
else
if (dt.Rows[0]["roleName"].ToString() == "مسئول خدمات")
{
Response.Redirect("K-Default.aspx");

}
else
{
Response.Redirect("P-Default.aspx");
}

}
else
{
L_Error.Visible = true;
T_Pass.Text = "";
T_UserName.Text = "";
}
}
}

*shidrokh*
چهارشنبه 02 مرداد 1392, 03:01 صبح
مشکلش حل شد. تو وب کانفیگ اسم کانکشن اشتباه تایپی داشت.