Solved

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

Posted on 2016-09-27
3
46 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41817875
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
ID: 41817912
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
ID: 41825241
Found my own solution
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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