Share via

My Code is giving this error System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Order'. Incorrect syntax near ')'. can someone assit me please

Ashantia Clarke 1 Reputation point
2021-11-17T03:09:10.827+00:00

emphasized text
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace _2021WEB2.Models
{
public class CommonFn
{
public class CommonFnx
{
//create new sqlconnection and connection to database by using connection string from web.config file
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolMS"].ConnectionString);
public void Query(string query)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
public DataTable Fetch(string query)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
}
}
}

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.