salve ragazzi,
ho appena pubblicato su un server aruba il mio sito. in locale premetto che funziona tutto. Ho creato un webservice per lavorare con le chiamate al db.
ecco il codice che utilizzo nel webservice:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System
Imports System.Data
Imports System.Web
Imports System.Data.SqlClient
Imports Telerik.Web.UI
<System.Web.Script.Services.ScriptService()> _
Public Class WebService
Inherits System.Web.Services.WebService
Private Const ItemsCategoryPerRequest As Integer = 10
Private Const ItemsCityPerRequest As Integer = 10
<WebMethod()> _
Public Function GetCategoryNames(ByVal context As RadComboBoxContext) As RadComboBoxData
Dim data As DataTable = Getcategoria(context.Text)
Dim comboData As New RadComboBoxData()
Dim itemOffset As Integer = context.NumberOfItems
Dim endOffset As Integer = Math.Min(itemOffset + ItemsCategoryPerRequest, data.Rows.Count)
comboData.EndOfItems = endOffset = data.Rows.Count
Dim result As New List(Of RadComboBoxItemData)(endOffset - itemOffset)
For i As Integer = itemOffset To endOffset - 1
Dim itemData As New RadComboBoxItemData()
itemData.Text = data.Rows(i)("descrizione").ToString()
itemData.Value = data.Rows(i)("id").ToString()
result.Add(itemData)
Next
REM ottengo il messaggio dei record selezionati
comboData.Message = GetStatusMessage(endOffset, data.Rows.Count)
comboData.Items = result.ToArray()
Return comboData
End Function
Private Function GetStatusMessage(ByVal offset As Integer, ByVal total As Integer) As String
If total <= 0 Then
Return "Nessun dato"
End If
Return [String].Format("Record <b>1</b>-<b>{0}</b> di <b>{1}</b>", offset, total)
End Function
Private Function Getcategoria(ByVal text As String) As DataTable
REM SELECT * FROM Tab_categorie WHERE CONTAINS(descrizione, @text)
REM per indici full text
Dim conString = ConfigurationManager.ConnectionStrings("TrycontactString")
Dim strConnString As String = conString.ConnectionString
Using scope As New Transactions.TransactionScope
Using db As New SqlConnection(strConnString)
db.Open()
Using sqlcmd As New SqlCommand("select_category", db)
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.Parameters.AddWithValue("@desc", SqlDbType.VarChar).Value = text
Dim adapter As New SqlDataAdapter(sqlcmd)
Dim data As New DataTable()
adapter.Fill(data)
Return data
End Using
End Using
scope.Complete()
End Using
End Function
End Class
ecco il codice aspx che richiama il webservice:
<WebServiceSettings Path="WebService.asmx" Method="GetCategoryNames" />
nella pagina aspx ho solamente queste registrazioni:
adesso quando online vado ad aprire la combobox che richiama il metodo del webservice mi esce il seguente messaggio: "The server method GetCategoryNames failed".
Ho provato a mettere il file asmx ed il file asmx.vb sia nella root principale del sito sia nella cartella app_code, ma niente da fare.
Dove sbaglio?
ciao
Cirillo Fabio
www.wondernet.biz
fabio@wondernet.biz
http://blogs.dotnethell.it/fabiocirillo/
http://wnetsoftware.blogspot.com