Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

use ajax, json object to call webservice in asp.net using VB and getting error method error 500 .Any help will be appreciated

$
0
0

HERE IS MY WEBSERCIE.ASMX.VB 

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports AjaxControlToolkit
Imports System.Collections.Specialized
Imports System.ComponentModel

' 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)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService1
Inherits System.Web.Services.WebService

Dim con As New ADODB.Connection
Dim conStr As String = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ToString

Public Function fetchid(knownCategoryValues As String, category As String) As CascadingDropDownNameValue()
If con.State = ConnectionState.Closed Then
con.Open(conStr)
End If
Dim cmd As New ADODB.Command
cmd.ActiveConnection = con
cmd.CommandText = "SELECT DISTINCT PD_MERCH_VMDB.VW_ADHOC_MER_SKU.SPPLR_ID AS supID, PD_MERCH_VMDB.VW_ADHOC_MER_SKU.PROD_CD as prodCD FROM PD_MERCH_VMDB.VW_ADHOC_MER_SKU"
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
'Dim adp As New Odbc.OdbcDataAdapter()
Dim ds As New DataSet()
' adp.Fill(ds)
con.Close()
Dim ids As New List(Of CascadingDropDownNameValue)()
For Each dtRow As DataRow In ds.Tables(0).Rows
Dim Suppid As String = dtRow("Supp_ID").ToString()
Dim prodcd As String = dtRow("PROD_CD").ToString()
ids.Add(New CascadingDropDownNameValue(Suppid, prodcd))
Next
Return ids.ToArray()
End Function


Public Function fetchils(knownCategoryValues As String, category As String) As CascadingDropDownNameValue()
Dim prodcd As Integer
Dim strIds As StringDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
prodcd = Convert.ToInt32(strIds("suppid"))
con.Open(conStr)
Dim cmd1 As New ADODB.Command
cmd1.ActiveConnection = con
cmd1.CommandText = "SELECT DISTINCT PD_MERCH_VMDB.vw_uda_adhoc.mer_uda_30_ds AS ILS,PD_MERCH_VMDB.VW_ADHOC_MER_SKU.SPPLR_ID AS supID, PD_MERCH_VMDB.VW_ADHOC_MER_SKU.SPPLR_NM AS supName FROM PD_MERCH_VMDB.VW_ADHOC_MER_SKU FULL OUTER JOIN PD_MERCH_VMDB.vw_uda_adhoc ON (PD_MERCH_VMDB.VW_ADHOC_MER_SKU.PROD_CD=PD_MERCH_VMDB.vw_uda_adhoc.prod_cd) where PD_MERCH_VMDB.VW_ADHOC_MER_SKU.SPPLR_ID =@Suppid"
cmd1.CommandType = ADODB.CommandTypeEnum.adCmdText

'here is tghe line to look
' cmd1.Parameters.AddWithValue("@Suppid", Suppid)
' cmd1.ExecuteNonQuery()


' Dim dails As New SqlDataAdapter()
Dim ds As New DataSet()
' dails.Fill(ds)
con.Close()
Dim ils As New List(Of CascadingDropDownNameValue)()
For Each dtRow As DataRow In ds.Tables(0).Rows
Dim ilscode As String = dtRow("ils").ToString()
Dim suppName As String = dtRow("Supp_Nm").ToString()
ils.Add(New CascadingDropDownNameValue(suppName, ilscode))
Next
Return ils.ToArray()
End Function


End Class

HERE IS MY ASPX PAGE NAMED AS HOME.ASPX

<%@ Page Language="vb" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="home.aspx.vb" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html>
<script runat="server">

Protected Sub Page_Load(sender As Object, e As EventArgs)

End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Default</title></head>

<body>
<form id="form1" runat="server" >
<asp:ScriptManager ID="Scriptmanager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManager>

<table>
<tr>
<td>Select ID:</td>
<td>
<asp:DropDownList ID="suppid" runat="server" Width="187px" />
<cc1:CascadingDropDown ID="csid" runat="server"
Category="suppid"
TargetControlID="suppid"
PromptText="-- Select --"
LoadingText="[Loading ...]"
ServiceMethod="fetchids"
ServicePath="~/WebService1.asmx" />

</td>
</tr>
<tr>
<td>Select ILS:</td>
<td>
<asp:DropDownList ID="ilslist" runat="server" Width="187px" AutoPostBack="false">
</asp:DropDownList>
<cc1:CascadingDropDown ID="csdils" runat="server"
ParentControlID="suppid"
Category="ils"
TargetControlID="ilslist"
PromptText="-- Select --"
LoadingText="Loading.."
ServiceMethod="fetchils"
ServicePath="~/WebService1.asmx"></cc1:CascadingDropDown>
</td>
</tr>
</table>

</form>

</body>
</html>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>