HI
I need to display 2 tables in one grid using the bands. I can not seem to find any sample code for this.
Do I need to adjust any of the properties on my grid in the design view?
How do I connect the 2 tables, with 1 SQL command or 2. Do I use one DataTable or 2?
Hello Marius,
There are many different approaches to solve this task, but the most important in your scenario is have two tables in one DataSet with DataRelation between these tables. I suppose that in your scenario, you have a database, that`s why I made small video tutorial , where I use MS SQL, two tables. TableAdatpers and so on...
Please watch the video and if you have any questions, feel free to write me
OK. In this case you should build your SQLCommand using SHAP. For example:
string sqlcommand = "SHAPE { SELECT ID, sText FROM dbItems WHERE ID =10} APPEND ({SELECT ID, sDescription FROM dbRows } RELATE ID TO ID) as Relation";
DataSet ds = new DataSet();
System.Data.OleDb.OleDbConnection nwindConn = new System.Data.OleDb.OleDbConnection("Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=IGBGSOFDS22;Integrated Security=SSPI;Initial Catalog=Test");
System.Data.OleDb.OleDbDataAdapter adap = new System.Data.OleDb.OleDbDataAdapter(sqlcommand, nwindConn);
adap.Fill(ds);
ds.Tables[1].TableName = "BBB";
ds.Tables[0].TableName = "AAA";
ds.Relations[0].RelationName = "HHH";
ultraGrid1.DataSource = ds;
Let me know if you have any further questions.
No, You could use your connection string. I just copy this code from one of my samples. The connection string is not related with our scenario and task.
Let me know if you have any questions.
Hi
I am not getting data in my datagrid view.
Here is my code
FieldsString = "SHAPE {SELECT [id] , [National_Id] from student } APPEND ( { SELECT [SETA], [OFO_Code] ,[ProgramName] FROM Qualification } RELATE ID TO ID) as relation "
Dim DS As DataSet = New DataSet
adp.Fill(DS)
DS.Tables.Add("Student")
DS.Tables.Add("Qualification")
DS.Tables.Add("Relation") ---> Where do you get the name ???
Grid_Select_Student_For_Edit.DataSource = DS
Hi,
If you use a SHAPE / APPEND syntaxes in your SQL command, then you should remove :
DS.Tables.Add("Relation")
I didn`t use Add() method in my snippet code (take a look on the previous response) Could you please upload your sample, I`ll be glad to research it for you.