Hi all,
I am trying to populate a data set with multiple sql tables. I understand that I need to do this with multiple sqlcommands but how do I break up an SQL Statement into seperate commands?
Thank you for any help you may offer.Code:"SELECT * FROM Part, Part_Type, Part_Subtype, Part_Type_Subtype_Xref, Part_Details_Motor WHERE Part.Part_Type_Xref = Part_Type_SubType_Xref AND Part_Type_SubType_Xref.Part_Type_Id = Part_Type.Part_Type_Id AND Part_Type_SubType_Xref.Part_SubType_Id = Part_SubType.Part_SubType_Id AND Part.Master_Part_Id = Part_Details_Motor.Master_Part_Id And Part_Type.Part_Type_Name = 'Motor Controller'" ************************************************************************ Dim firstSql As String Dim secondSql As String connectionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password" firstSql = "Your first SQL Statement here" secondSql = "Your Second SQL Statement Here" connection = New SqlConnection(sBOMConnectionString) Try connection.Open() command = New SqlCommand(firstSql, connection) adapter.SelectCommand = command adapter.Fill(ds, "First Table") adapter.SelectCommand.CommandText = secondSql adapter.Fill(ds, "Second Table")




Reply With Quote