我收到错误“在当前上下文中不存在名称'SqlHelper'” [英] i got error "The name 'SqlHelper' does not exist in the current context"

查看:458
本文介绍了我收到错误“在当前上下文中不存在名称'SqlHelper'”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用sp完成了sql中保存数据的代码

i完成了后续课程





i have done th code for save data in sql using sp
i have done the folling class


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);
        }

    }
   
}

推荐答案

使用使用Microsoft.ApplicationBlocks.Data;



SqlHelper不带System.Data.Sql;



你必须使用Microsoft.ApplicationBlocks。数据
Use "using Microsoft.ApplicationBlocks.Data;"

SqlHelper doesnt come with System.Data.Sql;

You have to use Microsoft.ApplicationBlocks.Data


SqlHelper类来自命名空间Microsoft.ApplicationBlocks.Data。这是我们应该从msdn获得的第三个工具方,并安装并将dll文件添加到我们的项目中。



你可以从这个网站下载dll

http://www.microsoft.com/downloads/details.aspx?FamilyID=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en [ ^ ]
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[^]


SqlHelper命名空间包含使用System.Data.Linq.SqlClient的头文件
SqlHelper namespace contains header file using System.Data.Linq.SqlClient


这篇关于我收到错误“在当前上下文中不存在名称'SqlHelper'”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆