ADO.NET :: Can Add New Column In Already Filled DataTable In Vb.NET
Mar 3, 2011I have a dataTable filled with data.
And I want to insert new column into same datatable without affecting original data.
I have a dataTable filled with data.
And I want to insert new column into same datatable without affecting original data.
What I have is a datatable being constructed from Sharepoint API. We dont need to worry about the sharepoint api.The code where it fills the data is as follows
Datatable dt = new datatable();
Sharepoint.fill(dt);
Write what I want is as the dt is being filled is to create another column called full path which has a formula col1+col2I dont want to do a for next loop after the dt is filled . very slow !
I have a suitation where i want to select only those columns only which contain any data blank, null or "0" values data couldn't retrive from query.
for eg.
SL NO Name Contact Address email remarks
01 Atul 0 Ranchi atul@hotmail.co.in
02 Atul 34753 fdsgsdfgdfs
what query i write which display only slno, name, address and email automaitcally for slno 1, or slno,name,contact and remarks for slno2.
I tried to query an excel file which contains a lot of customers' information but my problem is most of those don't have a specific column names. E.g. it's in the following format. (Excel File)
A B C
Info1 blur blur
Info2 blur blur
Info3 blur blur
So, when I query using SqlDbDataAdapter, in my DataTable, info1 blur blur becomes column header. e.g. it's in the following format. (DataTable)
Info1 blur blur
Info2 blur blur
Info3 blur blur
I been working on it so that it actually goes down one row and Change the column name in the DataTable into some appropiate name. Something like the following format.
Name1 Name2 Name 3
Info1 blur blur
Info2 blur blur
Info3 blur blur
Is there any way that I could work around it rather than actually going back to change the excel files ? Because I have like 1,000 excel files in that kinda format and seriously giving me headache now.
I'm using a DataSet to fill my gridview. The dataset contains several columns, like: direction - fromNumber - toNumberThe column direction can contain the values "incoming" or "outgoing". In my gridview, I would like to show only 2 columns, direction and from/to. If direction = "incoming", the values from fromNumber has to be inserted in "from/to". If direction = "outgoing", the values from toNumber has to be inserted in "from/to".I know I can use a TemplateField to show different text values in a column...But I have no idea how to do this when I want to show the values from a column...
<asp:BoundField DataField="direction" HeaderText="direction" HtmlEncode="false" />
[Code]....
If I am passed a datatable and I cant change the column structure..is there anyway to set an existing column to a Primary key so I can easily Find() the row I am looking for?
View 1 Repliesi have a datatable with several columns and rows. now i want to copy the last column fully (all rows) and create the new column with that values.
it means last column values sholud be moved to new column (now this is the last column).
I am grabbing an XML feed an throwing it into a dataset. I am looping through the datatable that is in the dataset and adding a column to the datatable (Distance) that is the result of a calculation. What I then need to do is sort the dataset on the new column (Distance) I added, but it is not working... Here is a sample of my code.
[Code]....
How do I get the column header of a datatable in a gridview which is displayed in a gridview I created. I need to get it so that I can use it as comparison.
View 1 RepliesThis is my datatable
[Code]....
I want to localize the columns names. Can you tell me how can I do this? I localized my .aspx pages, but I don't know how to localize the text in .cs files.
how can i sort the data in col of datatable or other way to sort
View 7 RepliesI have a datatable dt with 4 columns. I want to retrieve only distinct values from column1 of datatable.
How can I achieve this using c# code?
How do you add an extra column in a datatable which will be used for another query
View 3 Repliesi have list box, in that list box have some fields(SQL Table fields) in run time i arrange the fields(based on my requirement order) , based on the list i want to change the columns in data table dynamicaly. how i change the columns in the datatable.
View 6 Repliesi have a sum column in my datatable and want to add the values?
is compute a good method to use?
I have string value in the column of datatable.I would like to assign seq no to different value.if they have the same value, I would like to assign the same seq no.if there isn't has the value in the column, then assign a new seq no.how to do this?for example:
district no. district
1 hong kong
2 germary
3 canada
1 hong kong
using vb.net 2005.
I'm trying to a byte array column to a table but getting an exception:
<error>
datatype argument cannot be null
</error>
The code I have is:
[Code]....
Does anyone know the correct syntax for this?
I have a Datatable store in the Session. This Datatable has a column call Qty. I have one button on the page that will update the Qty. How can I update my DataTable Qty column?
[Code]....
I have a DataSet comprised of two DataTables. One of the DataTables is further comprised of the results of two different SQL calls. I need to alphabetize the results of those SQL calls. After the seconds set of results is added to the DataTable I tried the following but the end result (displayed on the page) did not alphabetize the returned results. There was no error. Can anyone advise me please. 'programs' is the DataTable name, title is the column name.
programs.DefaultView.Sort = "Title ASC";
I am getting a datatable from the SQL Server. In SQL Server the column headers are fine (mix of Capital and Small Letters). But when i am getting it in the front end, all the column names are in lower case. How can i get the column names in original Case.
View 3 Repliesi use a datatable to populate my gridview, how do i retrieve database to datatable's column?
View 3 Repliesi have a column seq_no in datatable. if the column with data 2,4,5 how can i have the max number of the column. C#
View 5 RepliesI am binding a table to a gridview in asp.net as such
grdIssues.DataSource = mdtIssues;
grdIssues.DataBind();
The problem is I cannot then control the column width, asp.net seems to decided on it's own what width each column should be. Methods such as
grdIssues.Columns[0].ItemStyle.Width = 100;
grdIssues.Columns[1].ItemStyle.Width = 100;
don't work because the columns are created dynamically. I cannot believe there isn't a way to do this short of manually creating each column and filling each row.
How can i add same fields for columns in a datatable. I wan to make a datatable which repeate column name of same type multiple times, but dot net dont allow me to add that, but i want to do that hw can i do that?
table.Columns.Add("S.NO", typeof(int));
table.Columns.Add("DC", typeof(string));
table.Columns.Add("DC", typeof(string));
table.Columns.Add("DC", typeof(string));
table.Columns.Add("ST", typeof(string));
table.Columns.Add("ST", typeof(string));
table.Columns.Add("AD", typeof(string));
table.Columns.Add("AD", typeof(string));
I am using following code to get the columns from excel into datatable. In that in my excel file columns started from C to E means columns A and B is blank(Headers also). When i am reading excel file into datatable that time it's taking columns C to E. I want A and B also.Means when i am reading file that time blank columns are avoiding. I want blank columns should be read.
Excel File Data:
A B C D E
1 2 3
5 6 7
And in Datatable i am getting:
C D E
1 2 3
5 6 7
So i want Columns in Datatable also just like excel.
String
connString = ApplicationSetting
.GenerateExcelProvider(FilePath);[code]....