【问题标题】:Converting SQL Server class vb to c# [closed]将 SQL Server 类 vb 转换为 c# [关闭]
【发布时间】:2015-12-30 09:14:30
【问题描述】:

如何转换此代码行

 Public Sub New()       
   /*'StoredProcedure USE*/
    MyBase.New(ConnectionStrings("MSSQL_DBConnectionString").ToString, "")
    Me.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
    Me.InsertCommandType = SqlDataSourceCommandType.StoredProcedure
    Me.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure
    Me.UpdateCommandType = SqlDataSourceCommandType.StoredProcedure
End Sub

我也尝试http://converter.telerik.com/,但没有得到结果。

public New() :base(ConnectionStrings("MSSQL_DBConnectionString").ToString, ""){
this.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
this.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
this.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure;
this.UpdateCommandType = SqlDataSourceCommandType.StoredProcedure;}

感谢您的帮助

【问题讨论】:

  • 你得到的错误是什么?确定在.ToString 之后没有遗漏一些括号吗?所以.ToString().
  • 错误说明了什么?此外,连接字符串可能使用了错误的括号() -> []

标签: c# asp.net sql-server vb.net vb.net-to-c#


【解决方案1】:

您必须在任何转换器中输入有效的 VB 代码才能获得有意义的结果(您的评论不是 VB 评论)。 C# 等效构造函数如下,但类名未知 - 将“类名”替换为封闭类的名称:

public <class name>() : base(ConnectionStrings["MSSQL_DBConnectionString"].ToString(), "")
{
   ///*'StoredProcedure USE*/
    this.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
    this.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
    this.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure;
    this.UpdateCommandType = SqlDataSourceCommandType.StoredProcedure;
}

【讨论】:

    猜你喜欢
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 1970-01-01
    • 1970-01-01
    • 2012-04-14
    • 2010-12-18
    • 2013-05-24
    相关资源
    最近更新 更多