private dsAccounts BindCustomerGridView() { //accesses Accounts.mdb database for the clsDataLayer string tempPath = Server.MapPath("Accounts.mdb"); clsDataLayer myDataLayer = new clsDataLayer(tempPath); //retrieve customer listings from data layer in GetAllCustomers() method dsAccounts customerListing = myDataLayer.GetAllCustomers(); //adds information from customerListing in tblCustomers to the grid view gvCustomerList.DataSource = customerListing.tblCustomers; //data binds gvCustomerList and inserts into the cache gvCustomerList.DataBind(); Cache.Insert("CustomerDataSet", customerListing); return(customerListing); }
private dsAccounts BindCustomerGridView() { // Pulls data from the database for use string tempPath = Server.MapPath("~/App_Data/Accounts.mdb"); clsDataLayer myDataLayer = new clsDataLayer(tempPath); // Adds data from the first to the second dsAccounts customerListing = myDataLayer.GetAllCustomers(); // Adds data from the first to the second gvCustomerList.DataSource = customerListing.tblCustomers; // Caches data collected gvCustomerList.DataBind(); Cache.Insert("CustomerDataSet", customerListing); return(customerListing); }
public DataSet GetCustomerXMLFile() { //creates new instance of DataSet DataSet xmlDataSet = new DataSet(); try { //Reads XML data from customers.xml file xmlDataSet.ReadXml(dataPath + "customers.xml"); } catch (System.IO.FileNotFoundException error) { //creates listings from the data layer in the GetAllCustomers() method dsAccounts customerListing = myDataLayer.GetAllCustomers(); customerListing.tblCustomers.WriteXml(dataPath + "customers.xml"); xmlDataSet.ReadXml(dataPath + "customers.xml"); } //returns xmlDataSet return(xmlDataSet); }
//Method to display customers in the table private dsAccounts BindCustomerGridView() { // Alternate paths below. Mine is in App_Data. // Depending on where you placed your Access database, // one of the following lines may work better: // tempPath = Server.MapPath("Accounts.mdb") // tempPath = Server.MapPath("~/FPDB/Accounts.mdb") string tempPath = Server.MapPath("~/App_Data/Accounts.mdb"); clsDataLayer myDataLayer = new clsDataLayer(tempPath); // Instance of object to retrieve and return customers dsAccounts customerListing = myDataLayer.GetAllCustomers(); // Proper configuration for the gridview gvApps.DataSource = customerListing.tblUsers; // Finally bind the data to ensure connectivity gvApps.DataBind(); Cache.Insert("CustomerDataSet", customerListing); return(customerListing); }
// Method to display info in the tblUsers.xml public DataSet GetCustomerXMLFile() { // Default data set DataSet xmlDataSet = new DataSet(); // Try-catch statement to return the listings try { // Check for customers.xml within App_Data. Could also be at the top head of folders. xmlDataSet.ReadXml(dataPath + "Users.xml"); } // Display errors. Had an error, because I didn't the file was missing. catch (System.IO.FileNotFoundException error) { // Add your comments here dsAccounts customerListing = myDataLayer.GetAllCustomers(); customerListing.tblUsers.WriteXml(dataPath + "Users.xml"); xmlDataSet.ReadXml(dataPath + "Users.xml"); } // Finally returns the result, the John Smiths' and Jane Does' info. return(xmlDataSet); }