esteimle - Friday, January 6, 2012 11:06 AM:
I made my custom federated item, and I can click list all on it and get a single item back in the main grid showing my part number. So far I can figure out the proper return procedure to send back multiple results to the main grid. Here's what I'm trying so far in my item onGet:
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection ();
// TODO: Modify the connection string and include any
// additional required properties for your database.
conn.ConnectionString =
"data source=MININT-PHRAUUK\sqlexpress;User Id=CIP_E_CIS_User;Password=Test1234;" +
"initial catalog=CIP_E;";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlDataReader reader;
Item res = this.newItem("CIP_PART");
//res.apply();
// try
//{
conn.Open();
// Insert code to process data.
cmd.CommandText = "SELECT * FROM CAPACITORS";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
//sqlConnection1.Open();
//res5 = res5.apply();
reader = cmd.ExecuteReader();
int i = 0;
while(reader.Read() && i < 5){
i++;
Item res5 = this.newItem("CIP_PART");
string newid = getNewID();
res5.setID(newid);
res5 = res5.apply();
res5.setProperty("part_number", reader["PART_NUMBER"].ToString());
//return res5;
res.appendItem(res5);
}
try{
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
return res;
Any advice is appreciated. Thank you
esteimle - Friday, January 6, 2012 11:21 AM:
ah never mind this worked:
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection ();
// TODO: Modify the connection string and include any
// additional required properties for your database.
conn.ConnectionString =
"data source=MININT-PHRAUUK\sqlexpress;User Id=CIP_E_CIS_User;Password=Test1234;" +
"initial catalog=CIP_E;";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlDataReader reader;
Item res = this.getInnovator().newResult("");
XmlElement resultNd = (XmlElement) res.dom.SelectSingleNode("/*/*/*");
//res.apply();
// try
//{
conn.Open();
// Insert code to process data.
cmd.CommandText = "SELECT * FROM CAPACITORS";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
//sqlConnection1.Open();
//res5 = res5.apply();
reader = cmd.ExecuteReader();
int i = 0;
while(reader.Read() && i < 5){
i++;
Item res5 = this.newItem("CIP_PART");
string newid = getNewID();
res5.setID(newid);
res5 = res5.apply();
res5.setProperty("part_number", reader["PART_NUMBER"].ToString());
//return res5;
resultNd.AppendChild(resultNd.OwnerDocument.ImportNode(res5.node, true));
}
try{
}
catch (Exception ex)
{
//MessageBox.Show("Failed to connect to data source");
}
finally
{
conn.Close();
}
return res;