G F

G F

  • NA
  • 44
  • 6.1k

String Construction - Create Table with Parameter

Jul 1 2020 8:32 PM
Hi,
 
I'm trying to create a table where a column value is variable.
 
I've tried this, but does not work:
  1. string insertQuery = "CREATE table bbb.temptable AS SELECT null Id, TDId, TerritoryName FROM bbb.traveldocumentsterritories WHERE TDId=@TDId";  
  2. MySql.Data.MySqlClient.MySqlCommand myCommand = new  
  3. MySql.Data.MySqlClient.MySqlCommand(insertQuery, connection);  
  4. check.Parameters.AddWithValue("@TDId", oldTDnumber);  
  5. myCommand.ExecuteNonQuery();  
TDID is the column name, and I want to pass the value with the variable OldTDnumber.
 
Any help would be appreciated!

Answers (1)