I’ve tried this for several hours but I cannot figure it our what’s wrong
var cmd = new SqlCommand();
cmd.Parameters.Clear();
cmd.Connection = mySqlConnection;
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"select Calle.Id_Calle FROM" +
"TominPredial.Calle as Calle,"+
"TominPredial.Colonia as Col," +
"TominPredial.Poblacion as Pob" +
"WHERE Calle.Nombre = @NombreCalle" +
"and Col.Id_Colonia = @id_col and Pob.Id_Poblacion = @id_pob";
cmd.Parameters.Add("@NombreCalle", nombreCalle);
cmd.Parameters.Add("@id_col", id_col);
cmd.Parameters.Add("@id_pob", id_pob);
cmd.ExecuteScalar()
It says incorrect syntax near “Calle”
There is no space between the lines:
This will make the query
... FROMTominpredial.calle ... pobWHERE ..which will generate a syntax error.You have to put spaces between the keywords in the end of the lines. Something like so: