Saturday, December 31, 2016

System Stored Procedures in SQL Server

Hi, Now this post we see that how can we get some basic information of SQL Server using SQL Stored Procedure. Some different SP are given below as an example.

System Stored Procedure
Reports Information on
sp_who
Current SQL Server users and processes
sp_lock
Active locks, as well as blocking and deadlock information
sp_spaceused
The amount of disk space that a table or a database uses
sp_helpdb
Databases and their objects
sp_monitor
SQL Server statistics, such as total processing time, number of reads and writes, and connections
sp_helpindex
Indexes on a table
sp_statistics
All indexes on a specific table

If there is any other better option,
Please share it here or mail to me arkaa4@gmail.com

Thank You,
Arka Gupta.

Wednesday, December 7, 2016

Read JSON Data using VB.Net

First, add reference the DLL file from this URL: https://www.dllme.com/dll/files/newtonsoft_json_dll.html

 Then imports these,
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

Now we can get the JSON file data in the Textbox,
Private Sub Button1_Click ()
        Dim address As String{JSON API/File}
        Dim client As WebClient = New WebClient()
        Dim reply As String = client.DownloadString(address)
        TextBox1.Text = reply
End Sub

Now we can get the each single Child node Data Value,
Dim json As JObject = JObject.Parse(Me.TextBox1.Text)
MsgBox(json.SelectToken("Grand_Node").SelectToken("Father_Node").SelectToken("Child_Node"))
MsgBox(json.SelectToken("Grand_Node.Father_Node.Child_Node"))

Now we can get the each single Child node Data Value using Loop
    Private Sub Button2_Click()
        Dim json As JObject = JObject.Parse(TextBox1.Text)
        Dim results As List(Of JToken) = json.Children().ToList

        Dim Sec1 As String
        Dim Sec2 As String
        Dim Sec3 As String
        Dim Ans1 As String
        Dim Ans2 As String
        Dim Ans3 As String

        For Each item As JProperty In results
            item.CreateReader()
            Select Case item.Name
                Case "questions"
                    For Each subitem As JObject In item.Values
                           Sec1 = subitem("section1")
                           MsgBox(Sec1)
                            Sec2 = subitem("section2")
MsgBox(Sec2)
                            Sec3 = subitem("section3")
MsgBox(Sec3)
                     Next

                Case "responses"
                    For Each subitem As JObject In item.Values
Ans1 = subitem("answer1")
MsgBox(Ans1)
                            Ans2 = subitem("answer2")
MsgBox(Ans2)
                            Ans3 = subitem("answer3")
MsgBox(Ans3)
                    Next
            End Select

        Next
    End Sub