我正在尝试根据用户输入的值从两个独立但相关的表(它们之间有一个外键)中获取数据。例如如果输入值textBox11
,我的SQL语句是:
SQLCommandText = "select Invoice_Name.Inv_Nu, Invoice_Name.Price, Invoice_Name.IDate, AddInfo.Case_Nu, AddInfo.PaperName, AddInfo.Page_Nu, AddInfo.Case_Type, AddInfo.Size from Invoice_Name full outer join AddInfo on Invoice_Name.L_Name = " + "'" + textBox11.Text + "'";
这似乎无法正常工作,我似乎无法找出原因。
我有两张桌子是:
Invoice_Name
------------
Inv_Nu
L_Name
Price
IDate
AddInfo
-------
Inv_Nu
Case_Nu
PaperName
PageNumber
Case_Type
Size
我希望用户输入L_Name
和程序来带回 L_Name 等于该值的两个表中的所有信息。这里的外键是取自 Invoice_Name 表的 Inv_Nu。
测试数据:
Invoice_Name:
Inv_Nu | L_Name | Price | IDate
01064 | Rami Isleem | 215 | 19/6/2013
AddInfo:
Inv_Nu | Case_Nu | PaperName | Page_Nu | Case_Type | Size
01064 | 100/20 | Alra'i | 21 | abc | 2x8