J'essaie d'accepter dynamiquement un nom de table en fonction des conditions satisfaites, le nom de la colonne est également sélectionné dynamiquement, tout comme la valeur de comparaison, mais je reçois une erreur lors de l'exécution. J'écris ce code en C# et mon backend est SQL Server 2005. S'il vous plaît aidez-moi.Prendre dynamiquement un nom de table sous forme aspx à l'aide du serveur SQL
Voici le code:
if(table=="studenttab")
table = "personal_detail";
thisconnection1.Open();
string p = field[0].ToString().ToLower();
string q = code[0].ToString();
SqlCommand thiscommand3 = thisconnection1.CreateCommand();
thiscommand3.CommandText = " Select * from '" + table + "' where '" + p + "' = '" + q + "' ";
// here it gives error "Incorrect syntax near 'personal_detail'." Dont understand!
SqlDataReader thisreader3 = thiscommand3.ExecuteReader();