locked
Error - The Name sp_Location does not exist in the current context RRS feed

  • Question

  • User1979860870 posted

    Hi

    public bool RecordNavigation(string SrcSql, SqlParameter[] paramArr, SrcType SourceType = SrcType.SqlQuery)
            {
                SqlCommand comm = new SqlCommand();
    
                try
                {
                    comm.CommandText = SrcSql;
    
                    if (SourceType == SrcType.SqlQuery)
                        comm.CommandType = CommandType.Text;
                    else if (SourceType == SrcType.Table)
                        comm.CommandType = CommandType.TableDirect;
                    else if (SourceType == SrcType.StoredProcedure)
                        comm.CommandType = CommandType.StoredProcedure;
    
                    comm.Connection = Cnn;
    
                    foreach (SqlParameter param in paramArr)
                        comm.Parameters.Add(param);
    
                    comm.Connection.Open();
                    if (comm.Connection.State == ConnectionState.Open)
                    {
                        if (comm.ExecuteNonQuery() > 0)
                            return true;
                    }
                }
                catch (Exception ex)
                {
    
                }
                finally
                {
                    comm.Parameters.Clear();
                    comm.Connection.Close();
                }
                return false;
            }
    
    
    public void AddLocation(Location location)
            {
                SqlParameter[] ParamArr = new SqlParameter[5];
                ParamArr[0] = new SqlParameter("@Code", location.Code);
                ParamArr[1] = new SqlParameter("@Name", location.Name);
                ParamArr[2] = new SqlParameter("@Street", location.Street);
                ParamArr[3] = new SqlParameter("@City", location.City);
                ParamArr[4] = new SqlParameter("@Action", "I");
    
                RecordNavigation(sp_Location, ParamArr, SrcType.StoredProcedure);
            }

    Thanks

    Friday, January 15, 2021 10:30 AM

Answers