小编Tec*_*Guy的帖子

错误消息:类型或命名空间定义,或预期的文件结束

我搜索过互联网,所有以前的答案都说分号丢失了.那不是问题.还有什么可以导致这个错误?在第三个站点,有几个人问了这个问题,但这种情况有所不同.

错误是> 类型或命名空间定义,或文件结束预期 d

 public partial class SeenSMS : System.Web.UI.UserControl
    {
    //temp sql connection
    //public SqlConnection mycon;
    SqlConnection mycon = new SqlConnection(@"Data Source=ASOFT20\MAMUT;Initial   Catalog=ViltraNew;UserID=sa;Password=sa123");


    protected void Page_Load(object sender, EventArgs e)
    {
        string[] msg_arr = Request.QueryString["arr"].Split('|');

        if (!IsPostBack)
        {
            string Moose = Request.QueryString[1];
        }

        if (msg_arr != null)
        {
            if ((msg_arr.Length == 3) && (msg_arr[1].ToLower() == "slett"))

            {
                int Hours = Convert.ToInt32(msg_arr[2]);

                if (Hours > 0)
                {   
                    string username = msg_arr[0];

                    SqlCommand com = new SqlCommand("SELECT count(*) as count  FROM Animal …
Run Code Online (Sandbox Code Playgroud)

c# c#-4.0

10
推荐指数
2
解决办法
9万
查看次数

小巧玲珑的bool类型返回规则

我使用dapper ORM.所以我使用两个规则Query&QuerySingle.查询返回列表&QuerySingle返回单个对象.

所以,我想得到一个bool类型.(其实我想得到一个bool是真或假记录)

我的查询

public IEnumerable<T> Query<T>(string SqlString) where T : class
{
    return this.conn.Query<T>(SqlString);
}
Run Code Online (Sandbox Code Playgroud)

那么,我怎样才能写bool类型返回?

c# sql asp.net-mvc orm dapper

9
推荐指数
1
解决办法
6997
查看次数

使用MVC 4和实体框架填充DropDownList

我正在开发MVC4和实体框架Application.I想填充DropDownList,我想将Category List绑定到Dodropdown列表

存储库代码

IList<Category> GetCategory();
Run Code Online (Sandbox Code Playgroud)

知识库

public IList<Category> GetCategory()
    {
        return (from c in context.Categories
                select c).ToList();

    }
Run Code Online (Sandbox Code Playgroud)

调节器

  public IList<Category> GetCategory()
    {
        return icategoryRepository.GetCategory();
    }
Run Code Online (Sandbox Code Playgroud)

之后我就在这里.如何将数据绑定到Dropdownlist?

我在这里查看代码

<label for="ProductType">Product Type</label>
       @Html.DropDownListFor(m => m.ProductType,new List<SelectListItem>)
Run Code Online (Sandbox Code Playgroud)

我的控制器代码

 public ActionResult AddProduct()
    {
        return View();
    }
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc entity-framework asp.net-mvc-4

8
推荐指数
2
解决办法
4万
查看次数

C#中"get"和"set"属性的目的是什么?

我看到一些get set方法来设置值.有谁能告诉我这个的目的?

public string HTTP_USER_NAME
{
      get 
      {
            return UserName; 
      }
      set 
      {
            UserName = value; 
      }
}

public string HTTP_USER_PASSWORD
{
      get 
      {
            return UserPwd; 
      }
      set 
      {
            UserPwd = value; 
      }
}
Run Code Online (Sandbox Code Playgroud)

其实为什么要用这些东西.对于全球访问,还是有其他原因导致此类事情?

c# asp.net c#-4.0

7
推荐指数
2
解决办法
3万
查看次数

Mapper 不包含 Initialize AutoMapper C# 的定义

我在 asp.net C# 项目中实现了 Auto Mapper,但出现错误:

Mapper 不包含 Initialize 的定义

我试过这个例子链接在这里

我已经粘贴了我的代码:

namespace NewsWeb.Web.Infrastructure
{
    public class AutomapperWebProfile:Profile
    {
        public AutomapperWebProfile()
        {
            CreateMap<DistrictDTO, District>().ReverseMap();
        }

        public static void Run()
        {
            Mapper.Initialize(a =>
            {
                a.AddProfile<AutomapperWebProfile>();
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的 Golbal.asax.cs 文件中:

 AutomapperWebProfile.Run();
Run Code Online (Sandbox Code Playgroud)

错误图像: 在此处输入图片说明

c# asp.net-mvc automapper

6
推荐指数
1
解决办法
5619
查看次数

无法在Textbox中动态分派扩展方法

在这里我将从ViewBag中获取一个值.但是出现以下错误.

特定错误消息是

编译器错误消息:CS1973:'System.Web.Mvc.HtmlHelper'没有名为'TextBox'的适用方法,但似乎有一个名称的扩展方法.无法动态分派扩展方法.考虑转换动态参数或调用扩展方法而不使用扩展方法语法.

控制器中的ViewBag

 ViewBag.Vat = tx.GetVatDetails().FirstOrDefault().Percentage; // result is 15.0 
Run Code Online (Sandbox Code Playgroud)

在我看来

 @Html.TextBox("vat",ViewBag.Vat); // in here that error occured
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

c# asp.net-mvc entity-framework asp.net-mvc-5

4
推荐指数
1
解决办法
6116
查看次数

(TS) 找不到模块“@angular/platform-server”

当我开发我的 Asp.net Core 2 / Angular 5 应用程序时。我收到以下错误。

(TS) 找不到模块“@angular/platform-server”。

我在这里附上了生成错误的屏幕截图。 在此输入图像描述

这里我也添加了 package.json 文件。

  {
  "name": "ASPCoreWithAngular",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "4.2.5",
    "@angular/common": "4.2.5",
    "@angular/compiler": "4.2.5",
    "@angular/compiler-cli": "4.2.5",
    "@angular/core": "4.2.5",
    "@angular/forms": "4.2.5",
    "@angular/http": "4.2.5",
    "@angular/platform-browser": "4.2.5",
    "@angular/platform-browser-dynamic": "4.2.5",
    "@angular/platform-server": "4.2.5",
    "@angular/router": "4.2.5",
    "@ngtools/webpack": "1.5.0",
    "@types/chai": "4.0.1",
    "@types/jasmine": "2.5.53",
    "@types/webpack-env": "1.13.0",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "3.2.1",
    "bootstrap": "3.3.7",
    "chai": "4.0.2",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "es6-shim": "0.35.3", …
Run Code Online (Sandbox Code Playgroud)

typescript2.0 asp.net-core-2.0 angular

4
推荐指数
1
解决办法
6923
查看次数

更改表和添加UNIQUE键会导致错误

我有一张叫做的桌子Animal.AnimalId是主键,我想将列设置AnimalType_id为UNIQUE(我有一个AnimalType表,需要在这里设置一个外键)

ALTER TABLE Animal
ADD UNIQUE Animal.AnimalType_id int
Run Code Online (Sandbox Code Playgroud)

两个表中都有数据,因此我无法删除表.

但是这会导致错误:

消息102,级别15,状态1,行2
'''附近的语法不正确.

sql sql-server sql-server-2008

3
推荐指数
1
解决办法
4万
查看次数

更改Bootstrap标签位置

我想把Bootstrap标签和文本框放到同一行(在这里我需要将标签放在文本框的前面)

码:

<div class="form-group">
</div>
<div class="col-md-4 col-md-offset-8">
    <label class="col-sm-2 control-label">Total Tax</label>
    <input type="text" class="form-control" id="tottax" />
</div>
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

twitter-bootstrap

3
推荐指数
1
解决办法
8232
查看次数

无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Collections.Generic.IList <>'

这篇文章有很多可能的重复.但我尝试了大多数,不幸的是我的错误仍然发生.

错误是:错误1无法将类型隐式转换'System.Collections.Generic.List<Report.Business.ViewModels.InvoiceMaster>''System.Collections.Generic.IList<ICSNew.Data.InvoiceHD>'.存在显式转换(您是否错过了演员?)

public IList<InvoiceHD> GetAllInvoiceMasterDetailsByInvoiceId(int InvoiceId)
{
    var dbMstDtl = ireportrepository.GetAllInvoiceMasterDetailsByInvoiceId(InvoiceId);

    var MstDtl = from mst in dbMstDtl 
                 select new Report.Business.ViewModels.InvoiceMaster 
                 {
                     ModifiedDate = mst.ModifiedDate,
                     SubTotal = Convert.ToDecimal(mst.SubTotal),
                     TotalDiscount = Convert.ToDecimal(mst.TotalDiscount),
                     VAT = Convert.ToDecimal(mst.VAT),
                     NBT = Convert.ToDecimal(mst.NBT),
                     AmtAfterDiscount = Convert.ToDecimal(mst.AmtAfterDiscount)
                 };

    return MstDtl.ToList();
}
Run Code Online (Sandbox Code Playgroud)

在一些帖子中,我看到这个东西在使用 return MstDtl.AsEnumerable().ToList();

但在我的情况下它也没有工作(得到错误)

c# linq

3
推荐指数
1
解决办法
5万
查看次数