Hi,
I am sending a couple of records from one Table to another one. But when I run these codes its showing me in runtime a error message like this:
Additional information: Incorrect syntax near the keyword 'IN'.
I need to resolv this situation please.
string myConnectionString;
myConnectionString = "Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\Copy_table_to_table\\WindowsFormsApplication1\\Database1.mdf; Integrated Security = True";
using (var con = new SqlConnection())
{
con.ConnectionString = myConnectionString;
con.Open();
using (var cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = @"INSERT INTO test2 IN 'C:\Copy_table_to_table\WindowsFormsApplication1\database1.mdb' " + @"SELECT * FROM test1";
cmd.ExecuteNonQuery();
}
con.Close();
}
Console.WriteLine("It's done!");
}

Jignesh KumarRank #91 · 22.9K reputationPosted Dec 11, 2018, 11:35 AM EST
IsraelRank #1,223 · 1.5K reputationPosted Dec 11, 2018, 11:59 AM EST
IsraelRank #1,223 · 1.5K reputationPosted Dec 11, 2018, 10:22 PM EST
IsraelRank #1,223 · 1.5K reputationPosted Dec 14, 2018, 4:25 AM EST