473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

To retrieve the column name.

12
Hi,

I am coding in C#.

I need help finding simple way to retrieve a fields (or
columns) collection from a Dataset without filling it
first.

I cannot find the property of columnname.
Please help..

Thanks.
Oct 16 '07 #1
2 860
Hi,
Try this code...


DataSet1.Tables[0].Rows[0][fieldname];


regards,
ruel




Hi,

I am coding in C#.

I need help finding simple way to retrieve a fields (or
columns) collection from a Dataset without filling it
first.

I cannot find the property of columnname.
Please help..

Thanks.
Oct 16 '07 #2
Expand|Select|Wrap|Line Numbers
  1. SqlConnection objconn = new SqlConnection("server=<ServerName>;database=<DatabaseName>;uid=<UserID>;pwd=<Pwd>");
  2. objconn.Open();
  3.  
  4. //This will not fill data as the where condition is specified as 1=2
  5. SqlDataAdapter sa = new SqlDataAdapter("select query where 1=2", objconn);
  6.  
  7. DataTable dt = new DataTable();
  8.  
  9. sa.Fill(dt);
  10.  
  11. for (int intLoop = 0; intLoop < dt.Columns.Count; intLoop++)
  12. {
  13. MessageBox.Show(dt.Columns[intLoop].ColumnName);
  14. }
Oct 16 '07 #3

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

Similar topics

2
by: John T. McCraw | last post by:
How can I retrieve just the column names from an Access table. I don't need the data, just the column names.
2
by: WhiteEagl | last post by:
Hello, I would need some help with this identity column problem in SQLServer. I have a database with two tables. The Parent table has an Identity column. Parent (ParentID IDENTITY, Name)...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
3
by: Tony Marston | last post by:
I am using PHP 4.4.4 with Oracle 10g Express Edition on Windows XP. I am trying to emulate in Oracle the SET datatype in MySQL and the ARRAY datatype in PostgreSQL I have the created a...
1
by: ahujasatna | last post by:
Hi all!! i am working on C#, ASP.Net with Sql server2000 and i am facing a problem, my Question is: "How to insert and retrieve images to/from Sqlserver2000 Database" I created a table...
5
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x...
1
by: Mel | last post by:
Anyone know how I would retrieve the MaxLength property of a column in my Access Database table? I know how to retrieve table data, for example the "Quote #" field in my example code below, but I...
9
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters...
8
by: RP | last post by:
I want to retrieve column names (Exact field names) of a table. How to do that?
14
by: zionlion | last post by:
I want to only retrieve the values of one column in mysql and use these values to plot a graph. I know how to echo these values. However, I am unable to write them seperately. Let's say I have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
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...

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.