在一个C#窗体中需要同时查询SQL数据库里的两个表,UseInfo和SelfRoom,以下是我写的代码,该如何更改?
public partial class SearchUseInfo,SearchSelfRoom : Form
{
public SearchUseInfo()
{
InitializeComponent();
}
public SearchSelfRoom()
{
InitializeComponent();
}
UseInfoService uis = new UseInfoService();
SelfRoomService uis = new SelfRoomService();
}
多谢各位了。
public partial class SearchUseInfo,SearchSelfRoom : Form
{
public SearchUseInfo()
{
InitializeComponent();
}
public SearchSelfRoom()
{
InitializeComponent();
}
UseInfoService uis = new UseInfoService();
SelfRoomService uis = new SelfRoomService();
}
多谢各位了。
select 列1,列2,、、、 from 表1,表2 where 条件然后在c#里面建立一个拥有两表所有列的实体类然后就读取数据,进行出来,就直接出来这个实体类就ok了
分开以个成功了,下一个也可以啊
是不是要Left Join
您写全点,要不大火都在猜
cmd.CommandTimeout = 0; cmd.CommandText = "fas.usp_VochrSelect";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@AdmCompanyID", SqlDbType.VarChar)).Value = item.AdmCompanyIDList;
this.Adapter.SelectCommand = cmd;
this.Adapter.TableMappings.Clear();
this.Adapter.TableMappings.Add("Table", "VochrTempHead");
this.Adapter.TableMappings.Add("Table1", "VochrTempDetail");
this.Adapter.Fill(ds);
public SearchUseInfo()
{
InitializeComponent();
} public SearchSelfRoom()
{
InitializeComponent();
}
这2个方法我比较费解!
c#中有这种写法吗 !