Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

C#
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;
    }
    }
}
Posted
Updated 26-Sep-15 22:34pm
v4
Comments
Wendelius 27-Sep-15 4:20am    
And on what line you get the error?
Zoltán Zörgő 27-Sep-15 4:22am    
Show us your connection string
Vijoy Arora 27-Sep-15 4:35am    
<connectionstrings><add name="MyConn" connectionstring="Data Sourse=\\SQLEXPRESS;Initial Catalog=ShoppingCartDB;Integrated Security=True" providername="System.Data.SqlClient">
sudipt kumar 27-Sep-15 12:47pm    
Please provide the actual screenshot of the error You are getting
Vijoy Arora 29-Sep-15 21:42pm    
i got the solution of my problem thanks for the help.

1 solution

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=...
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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