OleDbConnection connection = new OleDbConnection(@"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = E:\Computing\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\Database31.accdb");
connection.Open();
OleDbCommand command = new OleDbCommand("SELECT Cocktails.CID, Ingredients.Ingredient1" +
" FROM Cocktails INNER JOIN Ingredients" +
" ON Cocktails.ID = Ingredients.ID" +
" WHERE Cocktails.ID = 1",
connection);
OleDbDataReader reader = command.ExecuteReader();
if (reader.Read())
{
string result = reader.GetValue(0).ToString();
string result2 = reader.GetValue(1).ToString();
MessageBox.Show(result + result2);
}
connection.Close();
我是SQL的新手并尝试使用“内连接”从两个不同的表中提取信息,:'JOIN操作中的语法错误'。 是我得到的错误,不确定为什么。感谢
答案 0 :(得分:0)
鸡尾酒和配料必须是鸡尾酒和配料,就像你在FROM ... INNTER JOIN系列中有它们一样
答案 1 :(得分:0)
您指定的表名是错误的。
ON Cocktails.ID = Ingredients.ID