Solved

Conversion from C# to VB inserting "Key" ???

Posted on 2016-09-27
3
26 Views
Last Modified: 2016-10-02
In my following code (partial) the conversion adds  "Key ."
Which gives me an error on code in VB.
How do I handle this?

THIS CODE
                    using (SJVServiceClient client2 = new SJVServiceClient())
                    {
                        SearchResult res2 = new SearchResult();
                        res2 = client.GetResult(new GetResultRequest
                        {
                            RequestID = requestID,
                            Authentication = new Authentication
                            { UserName = "username", Password = "password6" }
                        });

                        if (res2.ProductResult != null)
                        {
                            var json = JsonConvert.SerializeObject(res2);
                            lblJason.Text = json.ToString();
                        }
                    }

Open in new window


Produces THIS CODE
Using client2 As New SJVServiceClient()
	Dim res2 As New SearchResult()
	res2 = client.GetResult(New GetResultRequest() With { _
		[b]Key [/b].RequestID = requestID, _
		Key .Authentication = New Authentication() With { _
			Key .UserName = "username", _
			Key .Password = "password" _
		} _
	})

	If res2.ProductResult IsNot Nothing Then
		Dim json = JsonConvert.SerializeObject(res2)
		lblJason.Text = json.ToString()
	End If
End Using

Open in new window

0
Comment
Question by:lrbrister
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Pawan Kumar Khowal
Comment Utility
Remove html codes..  from your produced code.try now.

Using client2 As New SJVServiceClient()
	Dim res2 As New SearchResult()
	res2 = client.GetResult(New GetResultRequest() With { _
		Key.RequestID = requestID, _
		Key.Authentication = New Authentication() With { _
			Key .UserName = "username", _
			Key .Password = "password" _
		} _
	})

	If res2.ProductResult IsNot Nothing Then
		Dim json = JsonConvert.SerializeObject(res2)
		lblJason.Text = json.ToString()
	End If
End Using

Open in new window

0
 

Accepted Solution

by:
lrbrister earned 0 total points
Comment Utility
Pawar... still received the same error.

Found my own solution.

    Protected Sub medServiceExclusion(ByVal requestID As Integer)
        Dim getResult = New GetResultRequest()
        Dim auth = New Authentication()
        auth.UserName = "user"
        auth.Password = "useeP"
        getResult.RequestID = requestID
        getResult.Authentication = auth

        Using client As New SJVServiceClient()
            Using client2 As New SJVServiceClient()
                Dim res2 As New SearchResult()
                res2 = client.GetResult(getResult)
                If res2.ProductResult IsNot Nothing Then
                    Dim json = JsonConvert.SerializeObject(res2)
                    Dim f As String = ""
                End If
            End Using
        End Using
    End Sub

Open in new window

0
 

Author Closing Comment

by:lrbrister
Comment Utility
Found my own solution
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now