Torna al Thread
Imports System
Imports System.Text
Imports System.Collections
Imports System.Web
Imports System.Web.UI
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports Newtonsoft.Json
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class dp
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function test() As String
Dim str As String
Dim strconn As String = "Data Source=xxx.xxx.xxx.xxx; Initial Catalog=xxx; Integrated Security=SSPI; Trusted_Connection=No; User Id=xxx; Password=xxx; MultipleActiveResultSets=True; Connection Timeout=30;"
Using myconn = New SqlConnection(strconn)
Using myadapter = New SqlDataAdapter("select top 1 * from tabella", myconn)
Using mydataSet = New DataSet
Using mycmd = New SqlCommand("select top 1 * from tabella", myconn)
myadapter.SelectCommand = mycmd
myadapter.Fill(mydataSet, "table")
str = JsonConvert.SerializeObject(mydataSet, Newtonsoft.Json.Formatting.Indented)
End Using
End Using
End Using
End Using
Return str
End Function
End Class