2015-12-30 40 views
-2

我怎样才能把这段代码转换线转换的SQL Server类VB到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;} 

谢谢您的帮助

+3

什么是你的错误?确定你在'.ToString'之后没有遗漏一些括号?所以'.ToString()'。 –

+2

错误说的是什么?另外,连接字符串可能会使用错误的括号'() - > []' – Ian

回答

0

您必须输入有效的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; 
}