473,581 Members | 2,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help converting .xml feed to SQL

49 New Member
Hi everyone,
I am currently working on a project that pulls data from sql and displays it in an html file. This is working fine, but I am trying to make it a little more fancy using this cool source code found here:


In the source code, it is pulling dummy data from an .xml file that stores all of the data. I would like to change the source of the data to a table in my sql 2005 (my real data). Can someone help me make the necessary changes to pull my data from SQL? Sorry for my beginner questions. All help is appreciated!

Here is my C# code that references the .xml file;

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.ComponentModel;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.IO;
  6. using System.Web;
  8. /// <summary>
  9. /// Summary description for CustomerDataObject
  10. /// </summary>
  11. [DataObject(true)]
  12. public class CustomersDataObject
  13. {
  14.     /// <summary>
  15.     /// 
  16.     /// </summary>
  17.     private DataSet _customers;
  19.     /// <summary>
  20.     /// 
  21.     /// </summary>
  22.     public CustomersDataObject()
  23.     {
  24.         this._customers = HttpContext.Current.Session["Customers"] as DataSet;
  26.         if (this._customers == null)
  27.         {
  28.             this._customers = new DataSet();
  29.             this._customers.ReadXml(HttpContext.Current.Server.MapPath(@"App_Data\customers.xml"));
  31.             HttpContext.Current.Session["Customers"] = this._customers;
  32.         }
  33.     }
  35.     /// <summary>
  36.     /// 
  37.     /// </summary>
  38.     public DataTable CustomerTable
  39.     {
  40.         get { return this._customers.Tables["customers"]; }
  41.     }
  43.     /// <summary>
  44.     /// 
  45.     /// </summary>
  46.     /// <returns></returns>
  47.     public DataView Select(string propertyName, string propertyValue)
  48.     {
  49.         EnumerableRowCollection<DataRow> query = null;
  50.         if (string.IsNullOrEmpty(propertyName) || string.IsNullOrEmpty(propertyValue))
  51.         {
  52.             query =
  53.                 from customer in this.CustomerTable.AsEnumerable()
  54.                 select customer;
  55.         }
  56.         else
  57.         {
  58.             query =
  59.                 from customer in this.CustomerTable.AsEnumerable()
  60.                 where customer.Field<string>(propertyName).Equals(propertyValue, StringComparison.CurrentCultureIgnoreCase)
  61.                 select customer;
  62.         }
  64.         return query.AsDataView();
  65.     }
  67.     /// <summary>
  68.     /// 
  69.     /// </summary>
  70.     /// <param name="columnName"></param>
  71.     /// <param name="count"></param>
  72.     /// <param name="prefix"></param>
  73.     /// <returns></returns>
  74.     public string[] GetCompletionList(string columnName, string prefix, int count)
  75.     {
  76.         //  find all of the rows that have values that start with
  77.         //  the provided prefix
  78.         EnumerableRowCollection<DataRow> query =
  79.             from customer in this.CustomerTable.AsEnumerable()
  80.             where customer.Field<string>(columnName).ToLower().StartsWith(prefix.ToLower())
  81.             select customer;
  83.         DataView view = query.AsDataView();
  85.         //  only return distinct values
  86.         System.Collections.Generic.List<string> items = new System.Collections.Generic.List<string>();
  87.         #region Distinct
  88.         for (int i = 0; i < count && i < view.Count; i++)
  89.         {
  90.             string value = view[i][columnName].ToString();
  91.             if (!items.Contains(value))
  92.             {
  93.                 items.Add(value);
  94.             }
  95.         }
  96.         #endregion
  98.         //  return the items
  99.         return items.ToArray(); 
  100.     }
  101. }
Aug 28 '09 #1
1 2348
2,878 Recognized Expert Specialist
Actually it's more of a C# question than a SQL Server question. Find that portion that you connect your code to an xml file and try replacing that with a DSN-Less connection to a SQL server. I would think the SELECT statement would be the same.

Good luck!!!

--- CK
Aug 29 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Kevin T. Ryan | last post by:
Hi all - I'm somewhat new to python (about 1 year), and I'm trying to write a program that opens a file like object w/ urllib.urlopen, and then parse the data by passing it to a class that subclasses HTMLParser.HTMLParser. On the web page, however, there is javascript - and I think that is causing an error in parsing the data. Here's the...
by: mickjames | last post by:
Hi, I'd like to include the whole web page content (as opposed to just the headlines) into RSS/XML to enable people to read them via rss feed readers. Question: how to convert HTML elements such as href, img, b, p, etc into XML? I've seen someone use the following in their RSS feed but I don't like it because <pre> doesn't produce a...
by: Chris | last post by:
Hi, I found this code that can solve a problem I have. It sends print direct to printer. Imports System Imports System.Text Imports System.Runtime.InteropServices <StructLayout(LayoutKind.Sequential)> _ Public Structure DOCINFO<MarshalAs(UnmanagedType.LPWStr)>
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant would you recommend? The w3c HTML validator mentions XHTML 1.0 Transitional, Basic, Strict, and XHTML 1.1. Would I be able to make my existing CSS...
by: chuck | last post by:
Hello, We are converting to a VB Dot Net application . We have a grid with multiple columns. The headings in each of the columns are long and so we have to wrap the headings and display them in two lines as the header...similar to the wrapping property in Excel. The Carriage return and line feed does not seem to work. It does'nt look like you...
by: Jon | last post by:
All, I'm extremely new to XML and have been given a project that at this time seems way over my head. Was hoping someone here could help. Basically, I need a page that functions much like pages at www.feedburner.com. When you publish a feed, users can click on any files associated with the feed that are displayed in a nice looking webpage...
by: shotokan99 | last post by:
hi guys, i want to have rss on my site and the page is written in php (mypage.php). what are the things i need? how to start to with it? pls help.. tnx
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Is it possible to convert a microsoft word document to pdf in .net code. If anyone has done this before, please let me know.
by: bhass | last post by:
I'm trying to make a basic RSS feed generator. I'm still a newb and I really need help. My aim is to have the user input all their desired settings then create an XML file in the same directory with all of their RSS settings. First I'd like it to ask the user how many articles it wants to put in the RSS feed. So it can loop the adding articles...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.