473,398 Members | 2,125 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,398 software developers and data experts.

Default DataColumn.ColumnName Property?

Situation:
I am using an OleDbDataAdapter to fill a DataSet's DataTable with data
from an Access database. The DataSet's DataTable is bound to a
DataGrid. After the OleDbDataAdapter.Fill method is called, the
DataGrid displays the column headings as the column names output from
the Access SQL query. I would like to change some of the styles for
certain columns in the DataGrid, so I first need to set the
DataGridColumnStyle.MappingName Property of each DataGridColumnStyle.
According to the .NET docs, "The MappingName property is usually set to
the ColumnName of a DataColumn."

Question:
What is the ColumnName Property of a DataColumn equal to when the
DataColumn is automatically created as a result of the
OleDbDataAdapter? Is it equal to the column heading string?

Nov 21 '05 #1
4 2438
Hi,

"bordsby" <bo*****@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
Situation:
I am using an OleDbDataAdapter to fill a DataSet's DataTable with data
from an Access database. The DataSet's DataTable is bound to a
DataGrid. After the OleDbDataAdapter.Fill method is called, the
DataGrid displays the column headings as the column names output from
the Access SQL query. I would like to change some of the styles for
certain columns in the DataGrid, so I first need to set the
DataGridColumnStyle.MappingName Property of each DataGridColumnStyle.
According to the .NET docs, "The MappingName property is usually set to
the ColumnName of a DataColumn."

Question:
What is the ColumnName Property of a DataColumn equal to when the
DataColumn is automatically created as a result of the
OleDbDataAdapter? Is it equal to the column heading string?


ColumnName is the name of the column as it appears in the query if you use
DataAdapter.

DataColumn:
- ColumnName : the name of the column as it appears in the query (if you
used DataAdapter)
- Caption : returns ColumnName unless it has been set to something else

If the DataGridColumnStyles are auto-generated then:
- MappingName = DataColumn.ColumnName
- HeaderText = DataColumn.ColumnName

so that's why the HeaderText in the grid is the same as the column names in
your query.

If you create the column styles yourself, then you have to set MappingName
and HeaderText yourself. MappingName should be set to one of the
DataColumn's ColumnName and HeaderText can be set to whatever you want.
HTH,
Greetings

Nov 21 '05 #2
Thank you for the clarification.

If the query uses an "AS" qualifier like

SELECT column AS [A Column Name With Spaces]

Will the spaces mess anything up? I don't think so since it wants a
string, but just to clarify....

Nov 21 '05 #3
Hi,

"bordsby" <bo*****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thank you for the clarification.

If the query uses an "AS" qualifier like

SELECT column AS [A Column Name With Spaces]

Will the spaces mess anything up? I don't think so since it wants a
string, but just to clarify....
DataColumn.ColumnName will be 'the column name with the spaces', it
shouldn't cause any problems. Though some people prefer not to use column
names or aliases that have spaces and do the formatting later (eg.
DataGridColumnStyle.HeaderText).
HTH,
Greetings

Nov 21 '05 #4
That seems like a better idea anyway, then I don't need the aliases...

I really appreciate the help.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J | last post by:
Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number...
4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
5
by: Larry Bird | last post by:
I've created a AlertDataClass below within the class I have tables and column that I've create. In the AlertDataAccess class I'm trying to insert data into my tables. AlertDataAccess is a Module...
6
by: Nina | last post by:
Hi Everyone, I have made a windows application using vb.net 2003. When user opens this application it will display a default location in a textbox. This application has to allow user to...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
11
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
3
by: Manuel | last post by:
Hi to all, I'm trying to copy a Datacolumn from a table to another, but with this code: destTable.Columns.Add(srcTable.Column); I got this error: Column 'colname' already belongs to another...
1
by: Mark Baldwin | last post by:
Steven Thanks for your reply, however the typed datasets are defined in the web service and there seems to way to open the partial class code window - double clicking on the design surface does...
3
by: mnishani | last post by:
Is there any way to add a default value to a datagrid column(for the whole column - eg : system date) . I'm using vs2003 and datagrid and using dataadapter to update the grid. Thanks in advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...

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.