将SQL Server类vb转换为c#

时间:2015-12-30 09:14:30

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

如何转换此代码行

 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;}

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

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

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;
}