1
Answer

Object reference not set to an instance of an object.

pethu raj

pethu raj

7y
240
1
Hi,
How can i solve the error "Object reference not set to an instance of an object." .
for the below code.
The error throws in RowUpdating line
cmd.Parameters.AddWithValue("@p1", NAME.Text)
Kindly give a solution for this
 
 
protected void getdata()
{
string s = "Select * from Empdetail";
cmd = new SqlCommand(s, conn);
cmd.CommandType = CommandType.Text;
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
singlegrid.DataSource = ds;
singlegrid.DataBind();
}

protected void singlegrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
singlegrid.PageIndex = e.NewPageIndex;
getdata();
}

protected void singlegrid_RowEditing(object sender, GridViewEditEventArgs e)
{
singlegrid.EditIndex = e.NewEditIndex;
getdata();
}

protected void singlegrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string bid = singlegrid.DataKeys[e.RowIndex].Value.ToString();
string s = "delete from Empdetail where EMPID=@p2";
SqlCommand cmd = new SqlCommand(s, conn);
cmd.Parameters.AddWithValue("@p2", bid);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
getdata();
}

protected void singlegrid_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
singlegrid.EditIndex = -1;
getdata();
}

protected void singlegrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string bid = singlegrid.DataKeys[e.RowIndex].Value.ToString();
TextBox NAME = (TextBox)singlegrid.Rows[e.RowIndex].FindControl("NAME");
TextBox DESIG = (TextBox)singlegrid.Rows[e.RowIndex].FindControl("DESIG");
string s = "update Empdetail set NAME=@p1, DESIG=@p2 where EMPID=@p3";
cmd = new SqlCommand(s, conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@p1", NAME.Text);
cmd.Parameters.AddWithValue("@p2", DESIG.Text);
cmd.Parameters.AddWithValue("@p3", bid);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
singlegrid.EditIndex = -1;
getdata(); 
Answers (1)
0
Rajkiran Swain

Rajkiran Swain

NA 33.9k 372.4k 7y
LDAP is mostly used by medium-to-large organi­zations. If you belong to one that has an LDAP server, you can use it to look up contact info and the like. Otherwise, if you were just wondering about this acronym, you probably don't need it. But feel free to read on to learn the story of this bit of Internet plumbing.
 
http://www.gracion.com/server/whatldap.html
https://stackoverflow.com/questions/239385/what-is-ldap-used-for
http://searchmobilecomputing.techtarget.com/definition/LDAP 
Accepted
0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
LDAP stands for Light weight Directory Access Protocol. It is mature, well-defined, open and industry protocol accessing and maintaining the entries(user info) over internet protocol. It helps to add new, update and delete entries. It is mostly used authentication purpose. If you work in MNC you will have AD user account, this nothing but your LDAP user account.
More info, follow below link,
 
https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
 
For sharepoint integration, follow below links that may help you:
 
http://www.c-sharpcorner.com/uploadfile/Roji.Joy/sharepoint-form-authentication-using-ldap/
 
https://blogs.msdn.microsoft.com/spblog/2014/09/26/configure-a-sharepoint-2013-web-application-with-forms-based-authentication-with-a-ldap-membership-provider/