Rahman Jalayer Rahman Jalayer - 3 months ago 17
Vb.net Question

How to use sqlparameter in vb.net

i have some codes in c# and want to convert to vb.net:

codes in c#:

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



public DataSet ShowList()
{
DataSet ds = new DataSet();

ds = e.ExecuteDataset(CommandType.StoredProcedure, "PrcShowList", new SqlParameter[] ({new SqlParameter("@Id",Id) });

return ds;


}


how to convert this code to vb.net. i am new in vb.net

Answer

I use this free online tool for conversion. http://converter.telerik.com/


Which gives:

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
'=======================================================

Although i did have to fix a small typo first where the parameter array was created