在运行我的Asp.Net项目时出现错误,我无法解决它 [英] On Running My Asp.Net Project I Got A Error And I Am Not Able To Solve It

查看:67
本文介绍了在运行我的Asp.Net项目时出现错误,我无法解决它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给我一​​个错误消息是关键字'data sourse'不支持。

这里是该类的代码我从哪里得到问题



giving me an error msg is that the keyword 'data sourse' not support.
and here is the code of that class from where i am getting the problem

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace Ecommersee.DataLayer
{

    public class DataAccess
    {
        public static string ConnectionString
        {
            get
            {
                return ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString();
            }
        }
        public static SqlParameter AddParameter(string parameterName, object value, SqlDbType DbType, int size)
        {
            SqlParameter param = new SqlParameter();
            param.ParameterName = parameterName;
            param.Value = value.ToString();
            param.SqlDbType = DbType;
            param.Size = size;
            param.Direction = ParameterDirection.Input;
            return param;
        }
        public static DataTable ExecuteDTByProcedure(string Name, SqlParameter[] Params)
        {
           SqlConnection conn = new SqlConnection(ConnectionString);
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandText = Name;
           cmd.Parameters.AddRange(Params);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter adopter = new SqlDataAdapter(cmd);
           DataTable dTable = new DataTable();
        try
        { 
        adopter.Fill(dTable);
        }
        catch(Exception ex)
            {
          }
    finally
    {
            adopter.Dispose();
            cmd.Parameters.Clear();
            cmd.Dispose();
            conn.Dispose();
}
    return dTable;
    }
    }
}

推荐答案

很可能你拼错了关键字连接字符串中的数据源。正确的单词是 Source 而不是 Sourse 。所以连接字符串看起来像

Most likely you have misspelled the keyword Data Source in your connection string. The correct word is Source instead of Sourse. So the connection string could look something like
Data Source=servername\instancename;Integrated Security=...


这篇关于在运行我的Asp.Net项目时出现错误,我无法解决它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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