السلام عليكم ورحمة الله وبركاته
اخواني اعضاء ومشرفين المنتدى .. عندي مشكله في كود الاضافة في الغرد فيو .. عندي غرد فيو وفيها اسم المستخدم وصورته .... وضفت فيها تمبلت فيلد وسويت فيها بتون .. وضغط عليه وكتبت كود الاضافة فيه
يعني الاسم الي اضغط عليه يضيفة لي الى غرد فيو ثانية .. لكن ماضبط معي وطلع لي فيه الخطاء هذه
---------------
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
------------------------
وهذه هو الكود .. بس اعتقد انه الكود فيه خطاء وخاصة عند السطر المضلل
string con;
con = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = con;
SqlCommand sqlcom = new SqlCommand();
sqlcom.Connection = sqlcon;
string command, taha;
int flag1 = 1;
int falg2 = 0;
command = "insert into firnd (name,frnd_name,flag1,flag2,img) values(@name,@frnd_name,@flag1,@flag2,@img)";
sqlcom.CommandText = command;
sqlcon.Open();
sqlcom.Parameters.AddWithValue("@name", Session["name"]);
sqlcom.Parameters.AddWithValue("@frnd_name", GridView1.SelectedRow.ID);
sqlcom.Parameters.AddWithValue("@flag1", flag1);
sqlcom.Parameters.AddWithValue("@flag2", falg2);
sqlcom.Parameters.AddWithValue("@img", Session["ali"]);
taha = sqlcom.ExecuteNonQuery().ToString();
sqlcon.Close();
GridView2.DataBind();
ياليت تصححو لي الكود هذه وخاصه عند السطر المضلل اعتقد انه الخطاء فيه لاني ماعرفت كيف اخليه يضيف الاسم الي اضغط عليه
والله يجلعه في ميزان حسناتكم
