VB.NET Conversion from C# Needed

I need the following code converted to VB.net from C#.  The original code comes from Microsoft:
http://support.microsoft.com/default.aspx?scid=kb;en-us;319264

Here's the code from the site listed above:
// Add namespaces at top.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

//Crystal Report Variables
CrystalReport1 crReportDocument = new CrystalReport1();

//'CrystalReport1' must be the name the CrystalReport
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();

//Crystal Report Properties
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
CrystalDecisions.CrystalReports.Engine.Table crTable;

//Then, use following code sample to add the logic in the Page_Load method of your Web Form:

crConnectionInfo.ServerName = "EnterServerNameHere";
crConnectionInfo.DatabaseName = "EnterDatabaseNameHere";
crConnectionInfo.UserID = "EnterUserIDHere";
crConnectionInfo.Password = "EnterPasswordHere";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
      crTableLogOnInfo = crTable.LogOnInfo;
      crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
      crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

CrystalReportViewer1.ReportSource = crReportDocument;
                        
LVL 1
simplemoneyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mani_saiCommented:
Here is the VB.Net Code:

You need have proper reference in your solution:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

       'Crystal Report Variables
        Dim crReportDocument As CrystalReport1 = New CrystalReport1

        'CrystalReport1' must be the name the CrystalReport
        Dim crTableLogOnInfo As TableLogOnInfoDim = New TableLogOnInfo
        Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo

        'Crystal Report Properties
        CrystalDecisions.CrystalReports.Engine.Database(crDatabase)
        CrystalDecisions.CrystalReports.Engine.Tables(crTables)
        CrystalDecisions.CrystalReports.Engine.Table(crTable)

        'Then, use following code sample to add the logic in the Page_Load method of your Web Form:

        crConnectionInfo.ServerName = "EnterServerNameHere"
        crConnectionInfo.DatabaseName = "EnterDatabaseNameHere"
        crConnectionInfo.UserID = "EnterUserIDHere"
        crConnectionInfo.Password = "EnterPasswordHere"
        crDatabase = crReportDocument.Database
        crTables = crDatabase.Tables

        For Each crTable In CrystalDecisions.CrystalReports.Engine.Table

            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)

        Next


        CrystalReportViewer1.ReportSource = crReportDocument

Thanks
0
Bob LearnedCommented:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim crReportDocument As CrystalReport1 = New CrystalReport1()
Dim crTableLogOnInfo As TableLogOnInfo = New TableLogOnInfo()
Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table

crConnectionInfo.ServerName = "EnterServerNameHere"
crConnectionInfo.DatabaseName = "EnterDatabaseNameHere"
crConnectionInfo.UserID = "EnterUserIDHere"
crConnectionInfo.Password = "EnterPasswordHere"
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables

For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In crTables

 crTableLogOnInfo = crTable.LogOnInfo
 crTableLogOnInfo.ConnectionInfo = crConnectionInfo
 crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

CrystalReportViewer1.ReportSource = crReportDocument


Bob
0
LacutahCommented:
   'Add to your imports
    Imports CrystalDecisions.CrystalReports.Engine, CrystalDecisions.Shared

    'In the declartions / form wide variables secion, add the following
    Private crReportDocument As New CrystalReport1()
    Private crTableLogOnInfo = New TableLogOnInfo()
    Private crConnectionInfo As New ConnectionInfo()

    Private crDatabase As CrystalDecisions.CrystalReports.Engine.Database
    Private crTables As CrystalDecisions.CrystalReports.Engine.Tables
    Private crTable As CrystalDecisions.CrystalReports.Engine.Table

    'Use the following code in your Page_Load method of your web form
    crConnectionInfo.ServerName = "EnterServerNameHere";
    crConnectionInfo.DatabaseName = "EnterDatabaseNameHere";
    crConnectionInfo.UserID = "EnterUserIDHere";
    crConnectionInfo.Password = "EnterPasswordHere";
    crDatabase = crReportDocument.Database;
    crTables = crDatabase.Tables;

    For Each crTable In crTables
        crTableLogOnInfo = crTable.LogOnInfo;
        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
        crTable.ApplyLogOnInfo(crTableLogOnInfo);
    Next
    CrystalReportViewer1.ReportSource = crReportDocument;
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Bob LearnedCommented:
Dog pile :)

Bob
0
mani_saiCommented:
Here is my working code, you can take it for your reference if you need it:

 'Build a connection string
       Dim crReportDocument As FunctionalTeamReport    '(this is my crystal report--- .rpt)
        Dim strConnection As String = ConfigurationSettings.AppSettings("ConnectionString")
        Dim objConnection As New SqlConnection(strConnection)

        Dim sqlString As String

       'Here i am building a string that execute a SQL Stored Proc:

        sqlString = "Execute FunctionalTeamReport "
        sqlString = sqlString & "'" & Trim(Request.QueryString("GroupNo")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("DecisionMakers")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("RecoveryExperts")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("OperationalStaff")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("ExecutiveStaff")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("EmergencyCertifiedPersonnel")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("VendorSupport")) & "',"
        sqlString = sqlString & "'" & Trim(Request.QueryString("EPLO")) & "'"

        Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
        crReportDocument = New FunctionalTeamReport

        For Each myTable In crReportDocument.Database.Tables
            myLogin = myTable.LogOnInfo
            myLogin.ConnectionInfo.Password = ConfigurationSettings.AppSettings("DevSQLPassword")                      myLogin.ConnectionInfo.UserID = ConfigurationSettings.AppSettings("DevSQLUserID")
            myTable.ApplyLogOnInfo(myLogin)
        Next


        Dim da As SqlDataAdapter
        da = New SqlDataAdapter(sqlString, objConnection)

        Dim ds As New DataSet
        da.Fill(ds, "FunctionalTeamReportDSTable")

        crReportDocument.SetDataSource(ds)


        crvCOGReportsIES.HasPageNavigationButtons = True
        crvCOGReportsIES.HasRefreshButton = False
        crvCOGReportsIES.HasGotoPageButton = False
        crvCOGReportsIES.HasZoomFactorList = False
        crvCOGReportsIES.HasSearchButton = False
        crvCOGReportsIES.DisplayToolbar = False
        crvCOGReportsIES.HasDrillUpButton = False
        crvCOGReportsIES.DisplayToolbar = True


        crvCOGReportsIES.ReportSource = crReportDocument

Thanks
0
weddellCommented:
Use this,

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

It's not totally perfect but it is very good
0
simplemoneyAuthor Commented:
Each response has some type of error, usually that TableLogOnInfoDim was not defined.  TheLearnedOne came the closest, so far, but I'm getting a VB error on the For loop, specifically on crTable which says "Variable crTable hides a variable in an enclosing block"

Thanks.
0
mani_saiCommented:
This is tested working code:
You can try with this for looping.

 For Each myTable In crReportDocument.Database.Tables
 myLogin = myTable.LogOnInfo
 myLogin.ConnectionInfo.Password = ConfigurationSettings.AppSettings("DevSQLPassword")             myLogin.ConnectionInfo.UserID = ConfigurationSettings.AppSettings("DevSQLUserID")
 myTable.ApplyLogOnInfo(myLogin)
 Next


thanks
0
Bob LearnedCommented:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim crReportDocument As CrystalReport1 = New CrystalReport1()
Dim crTableLogOnInfo As TableLogOnInfo = New TableLogOnInfo()
Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table

crConnectionInfo.ServerName = "EnterServerNameHere"
crConnectionInfo.DatabaseName = "EnterDatabaseNameHere"
crConnectionInfo.UserID = "EnterUserIDHere"
crConnectionInfo.Password = "EnterPasswordHere"
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables

For Each crTable In crTables

 crTableLogOnInfo = crTable.LogOnInfo
 crTableLogOnInfo.ConnectionInfo = crConnectionInfo
 crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

CrystalReportViewer1.ReportSource = crReportDocument

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.