Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi all........
C#
[WebMethod]
 [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string Inserttblval(string UserName, int CountryId, int IsActive)
{
int rowsInserted;
SqlConnection conn = new SqlConnection("Data Source=SREENI\\SQLEXPRESS;Initial Catalog=TestDB;User ID=sa;Password=sa123");
string sql = string.Format(@"INSERT INTO [TestDB].[dbo].[Table_1] ([CountryId],[UserName],[IsActive]) VALUES ({0},'{1}',{2})", CountryId,UserName, 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("CountryId,UserName, IsActive");
}




error is

Error 3 The type or namespace name 'ScriptMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\mine\webserviceasp.net1\App_Code\WebService.cs 39 5 webserviceasp.net1
Posted
Updated 25-Aug-14 17:43pm
v4

just add

C#
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

after
C#
[WebMethod]


ie.

C#
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string Inserttblval(string UserName, int CountryId, int IsActive)
{


}
 
Share this answer
 
Comments
harshavardhan12345678 25-Aug-14 6:58am    
where
harshavardhan12345678 25-Aug-14 23:44pm    
Error 3 The type or namespace name 'ScriptMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\mine\webserviceasp.net1\App_Code\WebService.cs 39 5 webserviceasp.net1
 
Share this answer
 
v2

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