Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetAllData() for custom domain-table
Message
De
08/12/2008 11:13:51
León Carpay
Carpay Automatisering
Pays-Bas
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
GetAllData() for custom domain-table
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01365978
Message ID:
01365978
Vues:
70
Hi, I'm looking for a way to retireve a subset from a sql-table. I have several key-value fields in the application which I store in one table. When I want to use the DataGridView in combination with a ComboBox I have to bind the ComboBox with a DataTable. MM doesn't support an overload for the GetAllData() method. I designed the (test) method below in the DomainRef class to populate the comboboxes. It works but I think there has to be better ways...
        public DataTable GetAllData2(int DomainID)
        {
            string cnStr;

            cnStr = mmAppBase.DatabaseMgr.GetConnectionString("BinaDB");
            using (SqlConnection cn = new SqlConnection(cnStr))
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM DomainRef WHERE DomainID = "  + DomainID.ToString() , cn);
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                DataTable dtStuff = new DataTable("stuff");
                adpt.Fill(dtStuff);
                return dtStuff;
            }
        }
gr leon
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform