الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

خطا بالكود في Cs

بدأه al3ren في 4 يونيو 2008 · 3 رد · 491 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

عندي خطا بالكود

Line 19: protected void BTNOk_Click(object sender, EventArgs e)

Line 20: {

Line 21: string conSTR = ConfigurationManager.ConnectionStrings["datauser"].ConnectionString;

Line 22: SqlConnection con = new SqlConnection(conSTR);

Line 23: string comSTR = "SELECT [userName], [Password] FROM [Members] WHERE UserName=@uname and Password=@upass";

الخطا بالسطر رقم 21 لكن كيف اصححه ؟

#3

رسالة الخطا عالتالي :

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:

Line 19: protected void BTNOk_Click(object sender, EventArgs e)

Line 20: {

Line 21: string conSTR = ConfigurationManager.ConnectionStrings["data"].ConnectionString;

Line 22: SqlConnection con = new SqlConnection(conSTR);

Line 23: string comSTR = "SELECT [userName], [Password] FROM [Members] WHERE UserName=@uname and Password=@upass";

Source File: c:\Documents and Settings\Administrator\Desktop\WebSite4_2\WebSite4\Control\Login.aspx.cs Line: 21

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

Control_Login.BTNOk_Click(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\Desktop\WebSite4_2\WebSite4\Control\Login.aspx.cs:21

System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75

System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBa

ckEvent(String eventArgument) +7

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

تم تعديل هذه المشاركة بواسطة al3ren في 4 يونيو 2008 في 13:32

مواضيع مشابهة