Hello, I am looking to delete all the information from a SQL server table using an AJAX function. Below is my C# method:
[WebMethod]
public static void deleteCertificado()
{
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString());
string strsql = "DELETE * FROM Fiel";
SqlCommand comando = new SqlCommand(strsql, conn);
comando.CommandTimeout = 36000;
comando.ExecuteNonQuery();
}
Here is my JavaScript function:
function testDel() {
if (confirm('Are you sure you want to delete this?')) {
$.ajax({
url: 'Delete.asmx/deleteCertificado',
type: 'Delete',
data: {},
success: function () {
alert("Record deleted successfully");
}
});
} else {}
I just want to call the method without any specific user ID or data. How can I achieve this? My field "data" is empty as I simply want to delete all the information of the table.