Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreive Last column name

Status
Not open for further replies.

waely

Programmer
Dec 7, 2003
227
US
hi,
can someone give me a tip how to, in my select statment, retreive my last column name and then if's not equal to certain value to add column to table?

example
if last column is year 2005 (Y05) I want to retrive this value and compare it to this year and if it doesn't match then add (Y06) column.

thank you very much.
 
sorry, I forgot to mention that I'm using VB.net with Sql server backend. thanks
 
What object are you using to store the data that is returned?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I'm using datasets and dataadapter
 
Well, without testing it, I guess it would go along the lines of:
Code:
        If myDataSet.Tables(0).Columns(dt.Columns.Count - 1).ColumnName = System.DateTime.Now.Year.ToString Then
            myDataSet.Tables(0).Columns.Add(System.DateTime.Now.AddYears(1).Year.ToString)
        End If


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top