I got error say this line have problem:<b>price = (decimal) cmd.ExecuteScalar(); </b> I supporse will get one result back. <b>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. </b>
public decimal LMQuery(string vehicleCatID,string postCode,string suburb,string state,string city) { string CS = ConfigurationManager.ConnectionStrings["DBLM3"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { decimal price = decimal.Zero; string sqlQuery = string.Empty; sqlQuery = "my query is running correct in sql server management"; SqlCommand cmd = new SqlCommand(sqlQuery,con); con.Open(); price = (decimal) cmd.ExecuteScalar(); return price; } }
Quote:"my query is running correct in sql server management"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)