-2
我在查詢兩個表時收到錯誤。 「'tbl_programme'附近語法不正確。」當我運行下面的代碼。我想從兩個表中檢索數據。從兩個表中獲取數據(查詢)
// Define the ADO.NET objects.
SqlConnection con = new SqlConnection(connectionString);
string selectSQL = "SELECT * FROM tbl_team";
SqlCommand cmd = new SqlCommand(selectSQL, con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet dsPubs = new DataSet();
// Try to open database and read information.
try
{
con.Open();
adapter.Fill(dsPubs, "tbl_team");
// This command is still linked to the data adapter.
cmd.CommandText = "SELECT * tbl_programme";
adapter.Fill(dsPubs, "tbl_student_project_choice");
DataRelation test = new DataRelation("test",
dsPubs.Tables["tbl_team"].Columns["teamId"],
dsPubs.Tables["tbl_student_project_choice"].Columns["choiceGroupId"]);
dsPubs.Relations.Add(test);
}