Click here to Skip to main content
12,753,418 members (34,701 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SQL-Server DataGrid
I make new column programmatically in c# windows application.

for (int i = 0; i < 10; i++)
            dataGridView1.Columns.Add(string.Format("colmun{0}", i), string.Format("number {0}", i));

I want to know how I can save these columns in database.

Thank in advance
Posted 18-Nov-12 10:38am
Updated 18-Nov-12 10:45am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to create the column in the database, or create a schema where you can store arbitrary values by storing a column name as well as the data.
aliprogrammer 18-Nov-12 15:43pm
I don't want to create column in database. I want to create column in C#. How can I do that?
Christian Graus 18-Nov-12 15:45pm
You can't store it in the database, unless the database has a place for you to put it. It's a horrible design, but you CAN write SQL that runs from C# to create a new column. You have the column in C#, so your question makes no sense at this point.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100