//--------------------------------------------------------------------- void OtherSnips1() { //--------------------------------------------- System.Data.SqlClient.SqlDataAdapter SqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(); System.Data.DataSet Dataset1 = new System.Data.DataSet(); Dataset1.Tables.Add(new System.Data.DataTable("Table1")); //<Snippet26> try { SqlDataAdapter1.Update(Dataset1.Tables["Table1"]); } catch (Exception e) { // Error during Update, add code to locate error, reconcile // and try to update again. } //</Snippet26> //--------------------------------------------- NorthwindDataSet northwindDataSet = new NorthwindDataSet(); //<Snippet12> string xmlData = northwindDataSet.GetXml(); //</Snippet12> //<Snippet13> string filePath = "ENTER A VALID FILEPATH"; northwindDataSet.WriteXml(filePath); //</Snippet13> //--------------------------------------------- //<Snippet15> NorthwindDataSetTableAdapters.RegionTableAdapter regionTableAdapter = new NorthwindDataSetTableAdapters.RegionTableAdapter(); regionTableAdapter.Insert(5, "NorthWestern"); //</Snippet15> //--------------------------------------------- //<Snippet16> System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection("YOUR CONNECTION STRING"); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "INSERT Region (RegionID, RegionDescription) VALUES (5, 'NorthWestern')"; cmd.Connection = sqlConnection1; sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close(); //</Snippet16> }
protected void Page_Load(object sender, EventArgs e) { var ds = new NorthwindDataSet(); using (var ta = new CustomersTableAdapter()) { ta.Fill(ds.Customers); ds.WriteXml(Server.MapPath("~/App_data/veri.xml"), System.Data.XmlWriteMode.WriteSchema); } }
public void ProcessRequest(HttpContext context) { _context = context; _req = context.Request; _res = context.Response; if (!string.IsNullOrEmpty(_req.QueryString["t"])) { switch (_req.QueryString["t"].ToLower()) { case "categories": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.FillByCategoryID(ds.Categories, int.Parse(_req.QueryString["id"])); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.Fill(ds.Categories); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; case "products": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByProductID(ds.Products, int.Parse(_req.QueryString["id"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else if (!string.IsNullOrEmpty(_req.QueryString["cid"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByCategoryID(ds.Products, int.Parse(_req.QueryString["cid"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.Fill(ds.Products); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; default: break; } } }