Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'JSONDemo.Service1'.

Source Error:


Line 1:  <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="JSONDemo.Service1" %>

Source File: /Service1.asmx    Line: 1
Posted
Updated 25-Aug-14 18:49pm
v3
Comments
ClimerChinna 21-Aug-14 0:29am    
string sql = string.Format(@"INSERT INTO [TestDB].[dbo].[Table_1] ([UserName],[CountryId],[IsActive]) VALUES ({0},'{1}','{2}')", UserName, CountryId, IsActive);

use above statement it may help you
harshavardhan12345678 21-Aug-14 0:31am    
countryId Int IsActive int
ClimerChinna 21-Aug-14 0:37am    
if isactive is int why did you give string in function parameters
there also you need to use int
ClimerChinna 21-Aug-14 0:39am    
look at solution2
harshavardhan12345678 21-Aug-14 0:45am    
now iam getting page like this



Directory Listing -- /WebSite8/

Monday, August 18, 2014 06:39 PM App_Code
Thursday, August 21, 2014 10:13 AM App_WebReferences
Thursday, July 31, 2014 02:23 PM Style
Wednesday, July 30, 2014 04:14 PM 35,980 14 - 1.jpg
Wednesday, July 30, 2014 04:14 PM 56,617 2014-07-30 - 1 (2).jpg
Wednesday, July 30, 2014 04:17 PM 35,561 2014-07-30 - 1.jpg
Friday, August 01, 2014 07:17 AM 803 aboutus.aspx
Thursday, July 31, 2014 04:20 PM 279 aboutus.aspx.cs
Wednesday, July 30, 2014 04:43 PM 2,371 calculator.aspx
Thursday, July 24, 2014 12:35 PM 1,098 calculator.aspx.cs
Friday, August 01, 2014 07:16 AM 508 category.aspx
Thursday, July 31, 2014 04:12 PM 280 category.aspx.cs
Friday, August 01, 2014 07:19 AM 546 contactus.aspx
Thursday, July 31, 2014 04:16 PM 281 contactus.aspx.cs
Thursday, July 31, 2014 10:49 AM 2,289 Datalistaspx.aspx
Thursday, July 31, 2014 10:47 AM 804 Datalistaspx.aspx.cs
Wednesday, July 30, 2014 04:40 PM 3,309 EmployeDetails.aspx
Thursday, July 31, 2014 09:36 AM 1,676 EmployeDetails.aspx.cs
Friday, August 01, 2014 02:55 AM 4,213 Gridview.aspx
Thursday, July 31, 2014 09:54 AM 774 Gridview.aspx.cs
Wednesday, July 30, 2014 04:15 PM 123,451 IMG_2770.JPG
Monday, August 18, 2014 05:31 PM 3,202 loginpage.aspx
Monday, August 18, 2014 05:27 PM 466 loginpage.aspx.cs
Friday, August 01, 2014 06:57 AM 1,347 MasterPage.master
Thursday, July 31, 2014 02:05 PM 290 MasterPage.master.cs
Friday, August 01, 2014 07:22 AM 877 MMasterpage.aspx
Thursday, July 31, 2014 02:09 PM 280 MMasterpage.aspx.cs
Friday, August 01, 2014 06:52 AM 1,488 placeholder.aspx
Wednesday, July 30, 2014 04:32 PM 436 placeholder.aspx.cs
Friday, August 01, 2014 02:41 AM 893 QueryStringParams.aspx
Friday, August 01, 2014 02:39 AM 565 QueryStringParams.aspx.cs
Thursday, August 14, 2014 10:33 AM 3,048 Registrationpage.aspx
Thursday, July 24, 2014 02:30 PM 1,308 Registrationpage.aspx.cs
Thursday, August 21, 2014 10:13 AM 9,009 Web.config
Monday, July 21, 2014 09:28 PM 1,360 Web.Debug.config
Monday, August 18, 2014 06:39 PM 93 WebService.asmx
Friday, August 01, 2014 07:37 AM 2,534 website.publishproj
Version Information: ASP.NET Development Server 11.0.0.0

use below code


public string InsertWebservice(int CountryId, string UserName, int IsActive)
    {
        int rowsInserted;
        using (SqlConnection conn = new SqlConnection(conStr))
       {
           string sql = string.Format(@"INSERT INTO [TestDB].[dbo].[Table_1] ([UserName],[CountryId],[IsActive]) VALUES ({0},'{1}',{2})", UserName, CountryId, IsActive);
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandText = sql;
           cmd.CommandType = CommandType.Text;
           conn.Open();
           rowsInserted = cmd.ExecuteNonQuery();
           conn.Close();
           cmd = null;
       }
       return string.Format("Thank you, {0} number of rows inserted!", rowsInserted);
    }
 
Share this answer
 
v2
Comments
harshavardhan12345678 21-Aug-14 3:23am    
iam getting error like this
public object Inserttblval(string p)
{
throw new NotImplementedException();
}
ClimerChinna 21-Aug-14 3:29am    
this is not the function where we have worked up to now right, check remaining code in your page
ClimerChinna 21-Aug-14 3:32am    
post complete code of your page
harshavardhan12345678 21-Aug-14 3:36am    
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1
{
width: 100%;
}
.auto-style2
{
height: 26px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<table align="center" class="auto-style1">
<tr>
<td>UserName</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
<td> </td>
</tr>
<tr>
<td>CountryId </td>
<td>
<asp:TextBox ID="TextBox2" runat="server">
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">IsActive</td>
<td class="auto-style2">
<asp:TextBox ID="TextBox3" runat="server">
</td>
<td class="auto-style2"></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</td>
<td> </td>
</tr>
<tr>
<td>Result:</td>
<td>
<asp:Label ID="Label1" runat="server" Text="">
</td>
<td> </td>
</tr>
</table>

</div>
</form>
</body>
</html>
harshavardhan12345678 21-Aug-14 3:38am    
protected void Button1_Click(object sender, EventArgs e)
{
WebService ws = new WebService();
Label1.Text = ws.Inserttblval("UserName,CountryId,IsActive").ToString();
}
first you need to create webmethod in webservice like below

C#
[WebMethod]
public string Inserttblval(int CountryId, string UserName, int IsActive)
{
int rowsInserted;
SqlConnection conn = new SqlConnection(your connectionstring);
string sql = string.Format(@"INSERT INTO [TestDB].[dbo].[Table_1] ([UserName],[CountryId],[IsActive]) VALUES ({0},'{1}',{2})", UserName, CountryId, IsActive);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
conn.Open();
rowsInserted = cmd.ExecuteNonQuery();
conn.Close();
cmd = null;
return string.Format("Thank you, {0} number of rows inserted!", rowsInserted);
}



next in aspx page add below code

XML
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $("[id*=Button1]").click(function () {
                var obj = {};
                obj.countryid= $.trim($("[id*=TextBox2]").val());
                obj.username= $.trim($("[id*=TextBox1]").val());
                obj.isactive= $.trim($("[id*=TextBox3]").val());
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/GetValues",
                    data: JSON.stringify(obj),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (r) {
                        alert(r.d);
                        document.getElementById('Label1').value = r.d;
                    }
                });
                return false;
            });
        });
    </script>
</head>


XML
<body>
<form id="form1" runat="server">
<div>

<table align="center" class="auto-style1">
<tr>
<td>UserName</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
<td> </td>
</tr>
<tr>
<td>CountryId </td>
<td>
<asp:TextBox ID="TextBox2" runat="server">
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">IsActive</td>
<td class="auto-style2">
<asp:TextBox ID="TextBox3" runat="server">
</td>
<td class="auto-style2"></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
<td> </td>
</tr>
<tr>
<td>Result:</td>
<td>
<asp:Label ID="Label1" runat="server" Text="">
</td>
<td> </td>
</tr>
</table>

</div>
</form>
</body>



add below code in CS Page


C#
using System.Web.Services;
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]
    public static string GetValues(int countryid,string username,int isactive)
    {
        WebService ws = new WebService();
        return ws.Inserttblval(countryid, username, isactive);
    }



}


accept solution if its working,
 
Share this answer
 
v7
Comments
harshavardhan12345678 22-Aug-14 0:55am    
error in cs page.
return ws.<pre>Inserttblval(eno, ename, salary);
ClimerChinna 22-Aug-14 0:56am    
remove <pre>
ClimerChinna 22-Aug-14 0:57am    
check solution once again i have modified it
harshavardhan12345678 22-Aug-14 0:59am    
after click button didn't show anything
harshavardhan12345678 22-Aug-14 0:59am    
blank page
C#
public string InsertWebservice(int CountryId, string UserName, string IsActive)
{
using (SqlConnection conn = new SqlConnection(conStr))
{
string sql = string.Format(@"INSERT INTO [TestDB].[dbo].[Table_1] ([UserName],[CountryId],[IsActive]) VALUES ('{0}','{1}','{2}')", UserName, CountryId, IsActive);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}


If this is not working, Check by debugging the function.
 
Share this answer
 
Comments
harshavardhan12345678 21-Aug-14 3:22am    
iam getting error like this
public object Inserttblval(string p)
{
throw new NotImplementedException();
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900