SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 487 | Next

Scott Klein

"Professional LINQ"


FabrikamDataContext context = new FabrikamDataContext("user idi
=username;password=password");
IEnumerable result =
from prod in context.ProductTypes
orderby prod.Name
select prod;
DataTable dt = new DataTable("ProductType");
DataColumn dc;
DataRow dr;
dc = new DataColumn();
320
Appendix A: Case Study
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "ID";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "Name";
dt.Columns.Add(dc);
foreach (ProductType product in result)
{
dr = dt.NewRow();
dr["ID"] = product.ProductTypeID;
dr["Name"] = product.Name;
dt.Rows.Add(dr);
}
cboProductType.DataSource = dt;
cboProductType.DisplayMember = "Name";
cboProductType.ValueMember = "ID";
Next, add the following code to the SelectedIndexChanged event of the cboProductType combo.
If (cboProductType.SelectedIndex > 0)
{
int ProductID = Convert.ToInt32(cboProductType.SelectedIndex);
DataSet ds = new DataSet();
string connectionInfo = "Data Source=avalonserver;Initial Catalog=Fabrikam;
user id=username;pwd=password";
SqlDataAdapter da = new SqlDataAdapter("select ProductID, Name,
Description, ManufacturerSKU, Cost, Price, QuantityOnHand FROM products
WHERE ProductTypeID = @ID", connectionInfo);
da.


Pages:
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6