I am trying to run an insert query through the table adapter and I go into query builder and create the insert query, I click execute query and it works, but, when I try to save the query I get an error message with a yellow exclamation point under the search criteria builder saying 'failed to get schema for this query'. The two tables are identical. All I want to do is send the data from one table to another table. I don't get it. Here is the code.
INSERT INTO [Test Input]
(Name, Chart)
SELECT Name, Chart
FROM Test
WHERE (Name = '1')
Let me know if someone knows what I am doing wrong

Insert Query Failed Schema
fafnir
The table adapter is expecting a select query. It will make a typed dataset from the returned columns. I would use a sql command to insert the values into an existing table with an insert into query
Dim conn As New SqlConnection("Server = .\SQLExpress;Database = NorthWind; Integrated Security = SSPI;")
Dim sb As New StringBuilder
sb.Append("INSERT INTO [Test Input]")
sb.Append(" (FirstName, LastName)")
sb.Append("Select FirstName, LastName ")
sb.Append("From Employees ")
Dim cmd As New SqlCommand(sb.ToString, conn)
Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
conn.Close()
End Try
Dika
StringBuilder sb = new StringBuilder();
sb.Append("INSERT INTO [Test Input]");
sb.Append(" (FirstName, LastName)");
sb.Append("Select FirstName, LastName ");
sb.Append("From Employees ");
SqlConnection conn = new SqlConnection(@"Server = .\SQLExpress;Database = NorthWind; Integrated Security = SSPI;");
SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
}
OscarKwok
NewbieDude
I really appreciate your response. I am writing the program in C#, so, if you could show me how to do this in that language, I would appreciate it. Let me know if you have any questions.