473,699 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sqldatareader not showing item property in class

1 New Member
i have written a class in which i have written methods to fill comboboxes. here is the code:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO ;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9.  
  10.  
  11. namespace DALayer
  12. {
  13.     class ClsFillControls  
  14.     {
  15.         MasterData md = new MasterData();
  16.        public  SqlDataReader sqlDR ;
  17.  
  18.         public void DisplayGrid(ref DataGridView  dgGrid, string sSql )
  19.         {
  20.             try
  21.             {
  22.                dgGrid.DataSource =md.ReturnDataTable ( sSql );
  23.             }
  24.             catch ( Exception ex )
  25.             {
  26.                 throw ex;
  27.             }
  28.         }
  29.  
  30.         public void FillCombobox( ref ComboBox cmbBox, string sSql )
  31.         { 
  32.             try
  33.             {
  34.                 sqlDR  = md.ExecReader( sSql );
  35.  
  36.                 cmbBox.Items.Clear();
  37.                 while (sqlDR.Read())
  38.                 {
  39.                     cmbBox.DataSource = sqlDR;
  40.                 }
  41.  
  42.                 sqlDR.Close();
  43.  
  44.             }
  45.             catch ( Exception ex )
  46.             {
  47.                 throw ex;
  48.             }
  49.         }
  50.  
  51.         public void FillMultiComboBox( ref ComboBox cmbBox1, ref ComboBox cmbBox2, string sSql )
  52.         {
  53.             try
  54.             {
  55.                 //SqlDataReader sqlDR = new SqlDataReader();
  56.                 sqlDR =md.ExecReader( sSql );
  57.                 cmbBox1.Items.Clear();
  58.                 cmbBox2.Items.Clear();
  59.                 while ( sqlDR.Read() )
  60.                 {
  61.                     cmbBox1.Items.Add( sqlDR(0) );
  62.                     cmbBox2.Items.Add( sqlDR );
  63.                 }
  64.                 sqlDR.Close();
  65.  
  66.             } 
  67.             catch ( Exception ex )
  68.             {
  69.                 throw ex;
  70.             }
  71.         }
  72.  
  73.         public void FillComboBox( ref DataGridViewComboBoxColumn cmbBox, string sSql )
  74.         {
  75.             try
  76.             {
  77.                 //SqlDataReader sqlDR;
  78.                 sqlDR = md.ExecReader( sSql );
  79.                 cmbBox.Items.Clear();
  80.                 while ( sqlDR.Read() )
  81.                 {
  82.                     cmbBox.Items.Add( sqlDR ) ;
  83.                 }
  84.             }
  85.             catch ( Exception ex )
  86.             {
  87.                 throw ex;
  88.             }
  89.  
  90.         }
  91.     }
  92. }
Please let me know where is the error
thank u
Sep 19 '13 #1
0 1028

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

Similar topics

4
1858
by: Perttu Pulkkinen | last post by:
Hi all php freaks! Do you think this kind of "property class" is useful or not? I have bee bored to the way I've been coding earlier. because: - often i have database-oriented classes like product, category, news etc. - often i have fex. load, request, insert, update and delete functions for them - often problems are the same ones: - which member variables are expected from the form, which ones are not
1
1506
by: Wael | last post by:
Hi, I created a custom control, but I can't add an item property to it. I tried the code below, but when I click the property, it shows a list of Objects. I can't figure out how to have items to hold only integers. Even with Objects, they seem to be readonly. I can't assign values to them. <Bindable(True), Category("Data"), DefaultValue("Item")> Property () As ArrayList
1
5230
by: Andrew Chen | last post by:
Hi: I've tried to use Hashtable.Item property, which should return a value according to the key assigned. But it returns an error saying the function does not exist in the class (it did not show up under intellisense either when I typed in the letter). Can someone tell me if this is a bug and how do I fix that? Andrew
4
1692
by: Dotnetjunky | last post by:
Hi, I'm really get confused on this issue. Hope that someone can help me get clear after this post. Take the class System.Web.Caching.Cache for example. In the documentation, there's a property called Item and the description is: "Gets or sets the cache item at the specified key. In C#, this property is the indexer for the Cache class."
2
4119
by: Wamiq Ansari | last post by:
Hi!, I am trying to add a value to a StringDictionary using its Item Property in C#. However this throws an expection as follows: Cannot implicitly convert type 'Component.TemplateComponent' to 'string'. The method I am using is as follows: private StringDictionary componentList = new StringDictionary(); public void addComponent(TemplateComponent docComponent)
4
12226
by: Marc van den Bogaard | last post by:
hello together, my datarow.item property is missing, i just can accesss the ItemArray property, what is wrong with this? System.Data.DataSet dataset1 = new System.Data.DataSet(); System.Data.DataTable datatable1 = new System.Data.DataTable("table1");
0
942
by: Andrés Giraldo | last post by:
Hi! I'm trying to creat a custom TabStrip Control, everything's ok but I want that in design time the developer creates each tab of the items property by a designer on the property tool box. I didn't ever work with designers, but I think it's no necesary to create one in this case, the Items property what I'm talkin is a item colleccion class that inherits from System.Collections.CollectionBase, so i just declare Items property as...
5
3933
by: Earl | last post by:
Noting first that I'm coming from VS2003 and VB.Net ... Using an untyped dataset, I create a dataview. When I try to use the Item property, "Item" does not appear on the Intellisense dropdown and I also get the build error "'System.Data.DataView' does not containt a definition for 'Item'." The documentation for VS2005 does show Item as a property of a dataview -- can anyone see the issue? DataView dvContacts = new DataView(ds.Tables);...
13
2852
by: lithoman | last post by:
I'm stumped here. I run the procedure Batch_Select against the database with @ID=18 and I get the expected data. When it loads into a SqlDataReader, it gets messed up somehow. Initially, after the reader.Read(), it has a row with 13 data columns, but they're all empty. So, my GetInt() function throws an error. When it jumps to the catch(), reader's columns then show the proper data. What gives? I have reader._data (which is the ID...
1
5283
by: mousumi123 | last post by:
Hello, http://www.jroller.com/djspiewak/entry/properties_files_in_ruby From this link i came to know that there is some Property class in ruby. So, i tried using it like this props=Properties.new props.load 'file.properties' But while running it is giving me NameError for Properties.
0
8704
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9192
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8940
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8895
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7781
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5879
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2362
muto222
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.