Click here to Skip to main content
15,616,639 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have done th code for save data in sql using sp
i have done the folling class


C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Sql;



/// <summary>
/// Summary description for infoaddup
/// </summary>
public class infoaddup
{
    infoaddup objinfo = new infoaddup();
    int Id;
    public int id
    {
        get { return Id; }
        set { Id = value; }
    }
    string Name;
    public string name
    {
        get { return Name; }
        set { Name = value; }
    }
    string Last_Name;
    public string last_Name
    {
        get { return Last_Name; }
        set { Last_Name = value; }
    }
    string Ph;
    public string ph
    {
        get { return Ph; }
        set { Ph = value; }
    }

    public infoaddup()
    {
        try
        {
            SqlParameter[] p = new SqlParameter[4];
            p[0] = new SqlParameter("@Id", SqlDbType.Int);
            p[0].Value = Id;
            p[1] = new SqlParameter("@Name", SqlDbType.NVarChar);
            p[1].Value = Name;
            p[2] = new SqlParameter("@Last_Name", SqlDbType.NVarChar);
            p[2].Value = Last_Name;
            p[3] = new SqlParameter("@Ph", SqlDbType.NVarChar);
            p[3].Value = Ph;

          //  int i = SqlHelper.ExecuteNonQuery(clsConnection.ConnectionString, CommandType.StoredProcedure, "ConsineeMaster_AddUpdate", p);
            int i = SqlHelper.ExecuteNonQuery(infoaddup.ConnectionString, CommandType.StoredProcedure, "infoaddup", p);
        }
        catch (Exception ex)
        {
            clsErrHandler.WriteError(ex);
        }

    }
   
}
Posted
Comments
Abhijit Parab 26-Sep-12 1:34am    
If SqlHelper is an object of SqlCommand then where u have defined in the code?
Member 10896619 5-Aug-14 8:32am    
In C++ what i'll use for sqlHelper Please tell me

Use "using Microsoft.ApplicationBlocks.Data;"

SqlHelper doesnt come with System.Data.Sql;

You have to use Microsoft.ApplicationBlocks.Data
 
Share this answer
 
Comments
Amit Bhoi 26-Sep-12 2:50am    
Thanx , But it give the error
"The type or namespace name 'ApplicationBlocks' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?"
Santhosh Kumar Jayaraman 26-Sep-12 2:52am    
You have to add it in the reference as well. I thought you already used it as reference. Why do you want to use SqlHelper.? You can just use sqlcommand rite?
SqlHelper Class comes from the namespace Microsoft.ApplicationBlocks.Data.This is a third tool party we should get from msdn and install and add the dll file to our project.

U can download the dll from this site
http://www.microsoft.com/downloads/details.aspx?FamilyID=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en[^]
 
Share this answer
 
v2
SqlHelper namespace contains header file using System.Data.Linq.SqlClient
 
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