Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

when i save the data it will save without any error but with in that save null columns.

For Example:

if i save id no 2 that saved successfully but before id no 1(one) added empty columns. here my code

DAL:

C#
#region InsertData
   public int Insert(NCBAL ObjInsert)
   {
       con = new SqlConnection(constr);
       con.Open();
       cmd = new SqlCommand("InsertNewComp_SP", con);
       cmd.CommandType = CommandType.StoredProcedure;
       try
       {
           cmd.Parameters.AddWithValue("@compliantID",ObjInsert.compid).ToString();
           cmd.Parameters.AddWithValue("@customerid", ObjInsert.cusid).ToString();
           cmd.Parameters.AddWithValue("@customername", ObjInsert.cusname).ToString();
           cmd.Parameters.AddWithValue("@branchid", ObjInsert.ddlbranch).ToString();
           cmd.Parameters.AddWithValue("@servicetype",ObjInsert.servicetype);
           return cmd.ExecuteNonQuery();
       }
       catch
       {
           throw;
       }
       finally
       {
           cmd.Dispose();
           con.Close();
           con.Dispose();
       }
   }
   #endregion



BAL:

C#
#region Insert Data
   public int Insert(NCBAL ObjInsert)
   {
       try
       {
           return ncd.Insert(ObjInsert);
       }
       catch
       {
           throw;
       }
       finally
       {
           ncd = null;
       }
   }
   #endregion



UI:
C#
ncb.compid = txtcompid.Text;
                        ncb.cusid = txtcusid.Text;
                        ncb.cusname = txtcusname.Text;
                        ncb.cusnum = txtcusnumber.Text;
                        ncb.compname = txtcompname.Text;
                        ncb.ddlproduct = DDlProductname.Text;
                        ncb.compliant = txtCompliant.Text;
                        ncb.compdate = Convert.ToDateTime(txtcompdate.Text);
                        ncb.solution = txtsolution.Text;
                        ncb.ddlassign = DDlAssign.Text;
                        ncb.datetocomp = Convert.ToDateTime(txtdatetocom.Text);
                        ncb.ddlpriorty = DDlPriorty.Text;
                        ncb.ddlstatus = DDlStatus.Text;
                        ncb.complianttime = txtcomplianttime.Text;
                        ncb.datetocomp = txtdatecomptime.Text;
                        ncb.ddlbranch = DDLbranch.Text;
                        String str = "";
                        for (int i = 0; i <= CBLservicetype.Items.Count - 1; i++)
                        {
                            if (CBLservicetype.Items[i].Selected)
                            {
                                if (str == "")
                                {
                                    str = CBLservicetype.Items[i].Text;
                                }
                                else
                                {
                                    str += "," + CBLservicetype.Items[i].Text;
                                }
                            }
                        }
                        ncb.servicetype = str;
                         int result = ncb.Insert(ncb);
                    }

How Can i Solve that...
Posted
Updated 15-May-14 22:40pm
v2
Comments
Abhinav S 16-May-14 4:32am    
Sorry your question is not clear.
prasanna.raj 16-May-14 4:35am    
when i try to store data it stored successfully but the same data stored double time...
[no name] 16-May-14 4:48am    
It means your insert method is calling 2 times. See it's may be in back end of UI code. Or your insert event is firing 2 times
DamithSL 16-May-14 4:47am    
update the question with InsertNewComp_SP code
OriginalGriff 16-May-14 4:48am    
You need to look at your stored procedure.

1 solution

Answered only to remove from unanswered list: solved by OP.
Thanks for all your valuable suggestion... i got the result...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900