micah says:
public
DataTable GetProfile(
string
username)
{
SqlConnection constr =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"conn"
].ConnectionString);
DataSet Dset =
new
DataSet();
SqlDataAdapter adapt;
Dset.Clear();
adapt =
new
SqlDataAdapter(
"GetUserPOSTS"
, constr);
adapt.Fill(Dset,
"GetUserPOSTS"
);
adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
adapt =
new
SqlDataAdapter(
"GetADPOST"
, constr);
adapt.Fill(Dset,
"GetADPOST"
);
adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
adapt.SelectCommand.Parameters.AddWithValue(
"@UserName"
, username);
adapt.SelectCommand.Parameters.AddWithValue(
"@Id"
, Id);
DataTable table1 =
new
DataTable();
DataTable table2 =
new
DataTable();
table1 = Dset.Tables[0];
table2 = Dset.Tables[1];
table2.Merge(table1);
GetMergedAll.DataSource = table2;
GetMergedAll.DataBind();
Replace the above method with the below.
public DataTable GetProfile(string username)
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
DataSet Dset = new DataSet();
SqlDataAdapter adapt;
Dset.Clear();
adapt = new SqlDataAdapter("GetUserPOSTS", constr);
adapt.Fill(Dset, "GetUserPOSTS");
adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
adapt = new SqlDataAdapter("GetADPOST", constr);
adapt.Fill(Dset, "GetADPOST");
adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
// adp.SelectCommand.Parameters.AddWithValue("@Email", username);
adapt.SelectCommand.Parameters.AddWithValue("@UserName", username);
adapt.SelectCommand.Parameters.AddWithValue("@Id", Id);
DataTable table1 = new DataTable();
DataTable table2 = new DataTable();
table1 = Dset.Tables[0];
table2 = Dset.Tables[1];
table2.Merge(table1);
return table2;
}