Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-09-27
3
Medium Priority
?
63 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 30

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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