SQL Server Performance

converting vbscript to vb.net

Discussion in 'SQL Server 2005 General Developer Questions' started by ubear, Oct 25, 2006.

  1. ubear New Member

    How would I convert the following code to vb.net? Thanks...


    '**********************************************************************
    ' Visual Basic ActiveX Script
    '************************************************************************

    Function Main()

    Dim objFSO, objFolder, colFiles, strFilesExists


    DTSGlobalVariables("ImportDirectoryPath").Value = DTSGlobalVariables("FileLocation").Value



    SET objFSO = CreateObject("Scripting.FileSystemObject")
    SET objFolder = objFSO.GetFolder(DTSGlobalVariables("FileLocation").Value)
    SET colFiles = objFolder.Files


    strFilesExists = "NO"

    If colFiles.Count > 0 Then
    For Each objFile In colFiles
    'Look to see if files exists
    IF UCASE(Left(objFile.Name, 3)) = "RCC" THEN

    'If atleast one exists move on
    DTSGlobalVariables("FileName").Value = objFile.Name
    DTSGlobalVariables("FileCreateDate").Value = Mid( DTSGlobalVariables("FileName").Value , 4 , 10 )
    DTSGlobalVariables("ConnectionString").Value =DTSGlobalVariables("FileLocation").Value + "" + objFile.Name
    strFilesExists = "YES"

    Exit For
    END IF
    Next
    End IF

    If strFilesExists = "NO" Then
    Main = DTSTaskExecResult_Failure
    Else
    Main = DTSTaskExecResult_Success
    End if



    End Function
  2. ranjitjain New Member

    I think with visual studio .net, there is a vb to .net code coversion utility.
    Still i feel you will be creating SSIS package for this and there is still option to execute vbscript and also to import visualbasic libraries.

    Considering the lines of code, i guess you are better off writing this in .net script on your own instead of running it as vbscipt in SSIS.
  3. ubear New Member

    Thanks for the fast reply, ranjitjain. Would you know where this tool is in the Microsoft Visual Studio for Applications environment that ships with SQL Server 2005? Or will I have to use visual studio.net?
  4. ranjitjain New Member

    Hi,
    In SSIS you can also add your existing vbscript as activex script task and then select the script language.
    Also long time back i had imported my vb code into .net
    but i dont remember how i did it
  5. ranjitjain New Member

    Hi,
    I found that option even under visual studio 2005.
    Open Visual studio,
    click on Open and then you will find convert option.
    Click on convert and then use vb upgrade wizard

Share This Page