Solved

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

Posted on 2016-09-27
3
54 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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