I'm loading a CSV file containing many thousands of rows into a .NET DataTable that looks something like this:
MyLocalDataTable
SequenceNo,
Etc
I have a table in an SQL database and I'd like to pull records into another datatable based on what I find in the CSV file.
MySQLBDTable
IdentityID,
SequenceNo,
Etc
The SequenceNo is my...
Hey,
Is there a elegant way, to bind predefined dataGridView columns with results from sql statement?
Example:
dataGridView1.Columns.Add("EID", "ID");
dataGridView1.Columns.Add("FName", "FirstName");
some sql like SELECT t.FirstName as FName, t.EmpID as EID FROM table t ...
and then I call dataGridView1.DataSource = someDataSet.Tab...
Is there a way to use a column of data from a DataTable to set the tag of a row automatically instead of having to iterate through each row in the DGV to manually assign it?
MyDataGridView.DataSource = GetDataTable();
foreach (DataGridViewRow dgvr in MyDataGridView.Rows)
{
dgvr.Tag = (int)dgvr.Cells[0].Value;
}
I have a large amount ...
I have a column in my DGV that is a custom type to display values of MyObjectType. My DataTable has the column created as MyObjectType, but the DGV creates a DataGridViewTextBox column and populates it with MyObjectType.ToString(); which is not the behavior I want.
Can I either force the data to be loaded into preexisting columns; or...
Hi,
I have a DataTable with 30+ columns and 6500+ rows.I need to dump the whole DataTable values into an Excel file.Can anyone please help with the C# code.I need each column value to be in a cell.To be precise,I need the exact looking copy of DataTable in an Excel File.Please help.
Thanks,
Vix
...
I would like to implement a "Group By" for my datatable. Has any one any suggestions?
update:
c#, .net 2.0
...
In C#, how can you calculate the size of a datatable object in memory?
We're using this to store various data groups, and would like to perform some logging/monitoring to aid in tuning the system.
However one of the pieces of information we need is the size of the datatable object.
Any ideas?
...
I have been looking around the internet for a way to display specific content from a sql data table. I was hoping that I could display the Content column according to the Id column value.
...
If all the items for a particular column are empty, I want to remove that column from the DataTable. What's the most elegant way to do this operation on all columns in the DataTable?
...
Guys,
I've always believed that DataTable would consume more memory than a generic List. I am testing loading a DataTable and loading a List from a SQL Server query. In this case, the DataTable is consuming less memory. I'm getting the top 2000 rows and there are 134 fields per row. One binary field and the rest are standard varchar, in...
I'm having some trouble updating changes I made to a datatable via a dataadapter. I am getting "Concurrency violation: the UpdateCommand affected 0 of 10 rows"
'Get data
Dim Docs_DistributedTable As New DataTable("Docs_Distributed")
Dim sql = "SELECT DISTINCT CompanyID, SortKey, OutputFileID, SequenceNo, DeliveredDate, IsDeliveryCodeCou...
I can't for the life of me work out what I am doing wrong here, despite much searching on SO/Google.
Basically I have a simple DataTable which is held in ViewState and adjusted during postbacks. When I try to write out the values, it is just an empty string. Please find below an abbreviated example of what I have - the output in this ca...
I have a collection
List<Employee> employees;
I use a DataTable, and load all the records (from MDB table) when Form1.Loads, and add these records to the List (Collection) so I work with them in memory.
Now, when I add a new employee to the collection, I should add it also to the mdb table... so I do:
DataRow rowemployee = Program...
This is a simple question, but I'm having trouble finding the answer.
I have a large datatable of which I have updated many, but not all rows.
I am using a dataadapter to update these changes to SQL server.
Does the dataadapter send update queries only for the updated rows from the datatable, or does it send one for every row, and esc...
the value buf has a datatype varbinary(max) and the value is 0x0000002D
string buF =
"0x" + BitConverter.ToString((byte[])dt.Rows[i]["BuF"]).Replace("-", "");
Label3.Text = buF;
i use the value to find the fileid
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection();
connection.Connec...
In writing some tests for a project I'm working on, I found that the best way for me to get the data back I needed about whether the project was correct was to put results into an ADO.NET DataTable. I got sick of setting breakpoints and waiting for them to be hit so that I could use the DataSet Visualizer to see what my results were, an...
I've a datatable bound to a gridview.
The datatable has the following data:
JobID Site Job List
--------- --------- --------- ---------
134 A job1 26
2241 A job2 25
124 A job3 26
244 B job1 12
154 B ads2 46
Am trying to take the count of distinct sites. So I write the following function:
public void CreateAdmins(DataTable...
Hi,
I came across a problem while updating a typed DataTable that has a primary key column.
At some point in my code I fill DataTables (some of them have primary and foreign key columns) and then I insert the data of all DataTables in one transaction using DataAdapters and Update(). Because the typed DataTables do not allow the PrimaryK...
Hello,
Let's say i have Datatable1 that has "Colum1" , "colum2"
and another table, Datatable2 with "Colum3" , "colum4"
I need to create Datatable3 that will contain all the columns "Colum1" , "colum2", "Colum3" , "colum4"
I need something smart, like the DefaultView.ToTable() method that does it for one table.
Thanks
...
I have read many posts on this topic; among them and most recently .NET - Convert Generic Collection to Data Table. Unfortunately, all to no avail.
I have a generic collection of structures :
Private Structure MyStruct
Dim sState as String
Dim lValue as Long
Dim iLayer as Integer
End Structure
Dim LOStates As New List(Of MyStruct)
I...