Click here to Skip to main content
11,578,954 members (64,905 online)
Rate this: bad
good
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 9:38am
Edited 18-Nov-12 9:45am
ridoy53.4K
v2
Rate this: bad
good
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.
  Permalink  
Comments
aliprogrammer at 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 at 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
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  

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

  Print Answers RSS
0 Peter Leow 135
1 Frankie-C 115
2 OriginalGriff 113
3 Richard MacCutchan 85
4 Afzaal Ahmad Zeeshan 85
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2015
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