如何在vb.net中使用SqlParameter

时间:2016-08-15 09:31:01

标签: c# vb.net

我在c#中有一些代码,想要转换为vb.net:

代码在c#中:

public Dataset ExecuteDataset(CommandType commandType, string commandText, SqlParameter[] commandParameters)
{
}


<code>public DataSet ShowList() {
  DataSet ds = new DataSet();
  ds = e.ExecuteDataset(CommandType.StoredProcedure, "PrcShowList", new SqlParameter[]({
    new SqlParameter("@Id", Id)
   });
   return ds;
}

如何将此代码转换为vb.net。我是vb.net的新手

1 个答案:

答案 0 :(得分:2)

我使用这个免费的在线工具进行转换。 http://converter.telerik.com/

给出了:

Public Function ExecuteDataset(commandType As CommandType, commandText As String, commandParameters As SqlParameter()) As Dataset

End Function

Public Function ShowList() As DataSet
    Dim ds As New DataSet()

    ds = e.ExecuteDataset(CommandType.StoredProcedure, "PrcShowList", New SqlParameter() {New SqlParameter("@Id", Id)})

    Return ds
End Function

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik
'Facebook: facebook.com/telerik
'=======================================================

虽然我必须先修改一个小错字,然后创建参数数组