Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:36:55+00:00 2026-06-17T19:36:55+00:00

I have created this vb.net file and it is working when i send a

  • 0

I have created this vb.net file and it is working when i send a string like this:

?data={"id":"12345","timestamp":"2012-03-03 12:00:00","latitude":"23.41223","longitude"="54.12345"}

but i also want it to work with a format like this:

?id=12345&timestamp=2012-03-03 12:00:00&latitude=23.41223&longitude=54.12345

How do i make this work in my vb.net file

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    
        If Not String.IsNullOrEmpty(Request.QueryString("data")) Then
            Dim data As String = Request.QueryString("data")

            Dim myObj As New MyObject
            Dim properties() As PropertyInfo = myObj.GetType().GetProperties()
            Dim values() As String = Server.UrlDecode(data).Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace(""":""", """=""").Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
            For Each value As String In values
                Dim keyValue() As String = value.Split(New Char() {"="}, StringSplitOptions.RemoveEmptyEntries)
                For Each prop As PropertyInfo In properties
                    If prop.Name.ToLower = keyValue(0).ToLower.Replace("""", "") Then
                        prop.SetValue(myObj, keyValue(1).Replace("""", ""), Nothing)
                    End If
                Next
            Next


        lblText1.Text = String.Format("ID: {0}", myObj.ID)
        lblText2.Text = String.Format("Longitude: {0}", myObj.Longitude)
        lblText3.Text = String.Format("Latitude: {0}", myObj.Latitude)
        lblText4.Text = String.Format("Timestamp: {0}", myObj.Timestamp)



    Cmd.Parameters.Clear()      
    Cmd.Parameters.AddWithValue("@ID", myObj.ID)
    Cmd.Parameters.AddWithValue("@Longitude", myObj.Longitude)
    Cmd.Parameters.AddWithValue("@Latitude", myObj.Latitude)
    Cmd.Parameters.AddWithValue("@Timestamp", myObj.Timestamp)

    Con.ConnectionString = "Data Source=servert\sql;Initial Catalog=table;Integrated Security=True"
        Cmd.Connection = Con
        Con.Open()
    Cmd.CommandText = "IF EXISTS (SELECT 1 FROM Locatie WHERE id = @ID) " & Environment.NewLine & _
                  "  BEGIN UPDATE Locatie SET Longitude = @Longitude, Latitude = @Latitude, Timestamp = @Timestamp WHERE id=@ID END " & Environment.NewLine & _
                  "ELSE " & Environment.NewLine & _
                  "   BEGIN INSERT INTO Locatie VALUES (@ID, @Longitude, @Latitude, @Timestamp) END "


     Reader = Cmd.ExecuteReader

        Reader.Close()
       Con.Close()
       Con.Dispose()



        End If

    End Sub

    Public Class MyObject
        Private _ID As String
        Private _Longitude As String
        Private _Latitude As String
        Private _Timestamp As String


        Public Property ID As String
            Get
                Return _ID
            End Get
            Set(value As String)
                _ID = value
            End Set
        End Property


        Public Property Longitude As String
            Get
                Return _Longitude
            End Get
            Set(value As String)
                _Longitude = value
            End Set
        End Property


        Public Property Latitude As String
            Get
                Return _Latitude
            End Get
            Set(value As String)
                _Latitude = value
            End Set
        End Property


        Public Property Timestamp As String
            Get
                Return _Timestamp
            End Get
            Set(value As String)
                _Timestamp = value
            End Set
        End Property


    End Class





</script>  

Where probably the key must be around here, so that there is also a second option where the second string is split set the values as id, longitude, latitude and timestamp:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load   
        If Not String.IsNullOrEmpty(Request.QueryString("data")) Then
            Dim data As String = Request.QueryString("data")

            Dim myObj As New MyObject
            Dim properties() As PropertyInfo = myObj.GetType().GetProperties()
            Dim values() As String = Server.UrlDecode(data).Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace(""":""", """=""").Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
            For Each value As String In values
                Dim keyValue() As String = value.Split(New Char() {"="}, StringSplitOptions.RemoveEmptyEntries)
                For Each prop As PropertyInfo In properties
                    If prop.Name.ToLower = keyValue(0).ToLower.Replace("""", "") Then
                        prop.SetValue(myObj, keyValue(1).Replace("""", ""), Nothing)
                    End If
                Next
            Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:36:57+00:00Added an answer on June 17, 2026 at 7:36 pm

    Do a check on the query string. If the string starts with data, then allocate values to the variables using the first method, else allocate values to variables by getting the value of the query string.

    Example:

    If Not String.IsNullOrEmpty(Request.QueryString("data")) Then
        'Use reflection logic
    Else
        MyObj.Longitude = Request.QueryString("longitude")
    End If
    

    Edit

    Example of the implementation within the provided Page_Load subroutine.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        Dim myObj As New MyObject
    
        If Not String.IsNullOrEmpty(Request.QueryString("data")) Then
            Dim data As String = Request.QueryString("data")
    
            Dim properties() As PropertyInfo = myObj.GetType().GetProperties()
            Dim values() As String = Server.UrlDecode(data).Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace(""":""", """=""").Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
            For Each value As String In values
                Dim keyValue() As String = value.Split(New Char() {"="}, StringSplitOptions.RemoveEmptyEntries)
                For Each prop As PropertyInfo In properties
                    If prop.Name.ToLower = keyValue(0).ToLower.Replace("""", "") Then
                        prop.SetValue(myObj, keyValue(1).Replace("""", ""), Nothing)
                    End If
                Next
            Next
        Else
            If Not (String.IsNullOrEmpty(Request.QueryString("id")) Then
                myObj.ID = Request.QueryString("id")
            Else
                myObj.ID = "Not set"
            End If
    
            If Not (String.IsNullOrEmpty(Request.QueryString("longitude")) Then
                myObj.Longitude = Request.QueryString("longitude")
            Else
                myObj.Longitude = "Not set"
            End If
    
            If Not (String.IsNullOrEmpty(Request.QueryString("latitude")) Then
                myObj.Latitude = Request.QueryString("latitude")
            Else
                myObj.Latitude = "Not set"
            End If
    
            If Not (String.IsNullOrEmpty(Request.QueryString("timestamp")) Then
                myObj.Timestamp = Request.QueryString("timestamp")
            Else
                myObj.Timestamp = "Not set"
            End If  
        End If
    
        lblText1.Text = String.Format("ID: {0}", myObj.ID)
        lblText2.Text = String.Format("Longitude: {0}", myObj.Longitude)
        lblText3.Text = String.Format("Latitude: {0}", myObj.Latitude)
        lblText4.Text = String.Format("Timestamp: {0}", myObj.Timestamp)
    
        'Rest of sub here
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a file named MyFile.db using SQLite3 from my C#.net application. This
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
I have this code in a .html.erb file: <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <script> FB.Event.subscribe('edge.create', function(response) {
To explain my question I have created this http://jsfiddle.net/Jams/XNVB2/ here I want when div1
I have created a fiddle to test this : http://jsfiddle.net/Ninjanoel/X6ShS/ which works fine :(
I have created a custom labeller for CC.Net which is working almost perfectly, however
I've my working on using the TPL in C# (.NET 4.0). I have created
I am working with a ASP.NET MVC4 application. I have created a view model
I'm working on a asp.net website and I have created a user control where
I have created a couple of web services of type .asmx (.NET) getting data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.