SqlConnection con=new SqlConnection (ConfigurationManager.ConnectionStrings["kumarConnectionString"].ConnectionString);
protected void Button1_Click1(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string firstSql = null;
//connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
firstSql = "select * from emp;";
firstSql += "select * from dep";
try
{
SqlCommand cmd = new SqlCommand(firstSql, con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
//creating data relations
DataRelation relation;
DataColumn table1Column;
DataColumn table2Column;
//retrieve column
table1Column = ds.Tables[0].Columns[0];
table2Column = ds.Tables[1].Columns[0];
//relating tables
relation = new DataRelation("relation", table1Column, table2Column);
//assign relation to dataset
ds.Relations.Add(relation);
Response.Write("Data relation completed");
}
catch (Exception ex)
{
Response.Write("Can not open con ! ");
}
}
Friday, December 17, 2010
Subscribe to:
Post Comments (Atom)
Good post,
ReplyDeletedid you try to implement it through the XSD schema?
Regards