w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Insert DataTable rows to DataBaseTables using DataAdapter: leave out one column in DataTable
string qry = "select * from PurchaseProduct where 0 = 1"; sa = new SqlDataAdapter(qry, conn); dataSet = new DataSet(); sa.Fill(dataSet); dataSet.Tables[0].Columns.Add("dtcolnPurchaseProductProductName",typeof(string));

Categories : Misc

For Loop of Datatable.rows breaks while exporting Datatable to excel in C# .Net
If I might offer an alternative: Use EPPLUS and its great LoadFromDataTable* Function - this would reduce your code to one line, it is magnitudes faster and it does not rely on Excel directly. Also: the library is free and can be included without licensing problems.

Categories : C#

Compare one datatable's rows to another datatable's columns
Not tested, but a simple loop on the dtReport columns collection checking if dtHeader columns collection contains a equal named column. If not remove the column from dtReport. SqlCommand cmdHeader = new SqlCommand("SELECT * FROM Header", conn); SqlCommand cmdReport = new SqlCommand("SELECT * FROM Report", conn); DataTable dtHeader = new DataTable(); DataTable dtReport = new DataTable(); SqlDataAdapter da1 = new SqlDataAdapter(cmdHeader); da1.Fill(dtHeader) SqlDataAdapter da2 = new SqlDataAdapter(cmdReport); da2.Fill(dtReport); for(int x = dtReport.Columns.Count - 1; x >= 0; x--) { DataColumn dc = dtReport.Columns[x]; if(!dtHeader.Columns.Contains(dc.ColumnName)) dtReport.Columns.Remove(dc.ColumnName); } The tri

Categories : C#

How to get distinct rows from datatable with 10 million rows?
If the database is SQL based, you can use SELECT DISTINCT. This will be much faster than anything you can do in c#. EDIT: There really isn't anything you can do. Switching to an embedded DBMS, such as SQLite, is your best option if you can feasibly do it.

Categories : C#

DataTable Row Count Returning 2 when only one VB.NET
(Presuming that you may actually have a header in your Excel document) This could be because it is counting your header as a row. In your connection string please specify HDR in Extended Properties like so: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:myFolder est.xlsx; Extended Properties="Excel 12.0 Xml;HDR=YES"; More information here: http://www.connectionstrings.com/excel/ If you are using ODBC as opposed to OleDB to connect then your connection string and drivers will be slightly different: http://www.connectionstrings.com/microsoft-excel-odbc-driver/

Categories : Vb.Net

DataTable Row count always returning 1
Your function will always return 1 because SELECT COUNT (*) FROM " statement will fill your datatable with 1 record, the number of count. If you want the row count use con.Open(); String cmdString = "SELECT COUNT (*) FROM " + "[" + Table +"]" OleDbCommand cmd = new OleDbCommand(); cmd.Text = cmdString ; cmd.Connection = con; int count = Convert.ToInt32(cmd.ExecuteScalar()); more quick and light for what you want. You do not have to use an object such datatable.

Categories : C#

Python cursor is returning number of rows instead of rows
You are storing the result of cur.execute(), which is the number of rows. You are never actually fetching any of the results. Use .fetchall() to get all result rows or iterate over the cursor after executing: for word in unique_multiples: like_str = '%' + word + '%' cur.execute("""SELECT * FROM vendor where name like %s""", like_str) for row in cur: print row

Categories : Python

how to make a void returning a datatable?
you can use class members for storing the datatable. public DataTable Price_dt(string tickername, bool isSubIndex) { DoMyThing(); this.setDT(real_time); } i'm pretty sure you have to (/should) use an invoke for setting the table (therefore the function). you can reffer the "stored" table in every other part of your class. hope this helps

Categories : C#

dataTable.DefaultView.Rowfilter always returning first row
Try creating a DataView from your datatable and run the filter based on that. Below is a quick example i tried and it works fine. DataTable dt = new DataTable(); dt.Columns.Add("bool", typeof(Boolean)); dt.Rows.Add(true); dt.Rows.Add(false); dt.Rows.Add(true); DataView dv = new DataView(dt); dv.RowFilter = "bool = 1"; foreach (DataRowView drv in dv) { Console.WriteLine(drv[0].ToString()); }

Categories : C#

Getting error in fiddler when returning datatable from WCF service
I managed to find another way. I am not sure if thats clever. What i did is to convert that datatable to list and return list. So i added below code in my service foreach (DataRow row1 in dt.Rows) { var list = new LookUpTable(); list.Name = (string) row1["Name"]; list.Id = row1["Id"]; myReturnList.Add(list); } return myReturnList.ToList();

Categories : Knockout Js

DataTable.Columns[0].Container returning null
Read the documentation: [BrowsableAttribute(false)] public virtual IContainer Container { get; } Property Value Type: System.ComponentModel.IContainer An object implementing the IContainer interface that represents the component's container, or null if the component does not have a site. This is a virtual property, inherited from the base class. It doesn't make sense for a DataTable. It's almost certainly not the property you wanted to use.

Categories : C#

EXPLAIN rows always returning all rows in table
From MySQL documentation: The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. EXPLAIN describes how result is collected, LIMIT is only restricts which rows should be returned from the previously collected result.

Categories : Mysql

Selecting one or more rows in a datatable
A datatable isn't a user interface construct, it's used for storing data. You'll need to bind your data table to some kind of UI construct, like a GridView -- and then worry about your mouse clicks.

Categories : Vb.Net

datatable.js displaying all the rows
The aaData should only be 10 long. So it should be: return Json(new { iTotalRecords = oList.Count(), iTotalDisplayRecords = oList.Count(), aaData = oList.Take(10) }, JsonRequestBehavior.AllowGet);

Categories : Asp Net Mvc

How do I add gridView rows to a dataTable?
Try this : DataTable finalShowsTable = new DataTable(); finalShowsTable = originalFinalShowsTable.Clone(); foreach (GridViewRow gvr in gvShows.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { if (((CheckBox) gvr.FindControl("cbSelect")).Checked) { DataRow dr= finalShowsTable.NewRow(); for (int i = 0; i < gvr.Cells.Count - 1; i++) { dr[i] = row.Cells[i].Text; } finalShowsTable.Rows.Add(dr); } } }

Categories : C#

Delete rows that contains null value from dataTable
public static void RemoveNullColumnFromDataTable(DataTable dt) { for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (dt.Rows[i][1] == DBNull.Value) dt.Rows[i].Delete(); } dt.AcceptChanges(); }

Categories : C#

Adding multiple rows to DataTable
my question is that what is the difference between both the steps and which one is better way performance wise? There isn't any difference a part from the order in which the assignment of data is performed. And there won't be any difference in performace either.

Categories : C#

How to sort particular colum rows in datatable
I think that select will do the trick. It has a sorting option http://msdn.microsoft.com/en-us/library/way3dy9w.aspx

Categories : C#

Update Primefaces datatable Rows
If I've understood you right, You just want to create table with edit function. For solving this trouble just pass your table and your button to form. <h:form> <p:dataTable var="gam" value="#{gamePlayerMB.listGamePlayerGuest}"> ... </p:dataTable> <p:commandButton value="Save States" action="#{gamePlayerMB.testRadioGuest}" /> </h:form> In this case on Save-button click all form will be sent to the server (with all your changing). Your testRadioGuest method may looked like this private void testRadioGuest(){ for(Player player: listGamePlayerGuest){ System.out.println(player); } } All state changing must be saved.

Categories : JSF

p:datatable rows by default editable
The body tag has onload event that trigger event when page is loaded, so you can trigger click event to pen icon by: <body onload="$('.ui-icon.ui-icon-pencil').click();">

Categories : JSF

Sum of Rows in DataTable by LinkedId in Gridview
I think your query should be like this SELECT TicketID, DisplayNum, TranstypeDesc, SubQueueId, SUM(EstimatedTransTime),LinkedTicketId FROM vwQueueData WHERE (DATEADD(day, DATEDIFF(day, 0, Issued), 0) = DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)) AND QId = @QId AND SubId = @SubId AND Called IS NULL group by LinkedTicketId try this and let me know if any wrong there

Categories : C#

How to edit datatable rows in Gridview
Here is the markup you need to create an EditItemTemplate within your TemplateField: <asp:GridView ID="GridView2" runat="server" Visible="False" AutoGenerateColumns="false" ShowFooter="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"> <Columns> <asp:BoundField DataField="RowNumber" HeaderText="Row Number" /> <asp:TemplateField HeaderText="Action Item"> <ItemTemplate> <asp:TextBox ID="TextBox1" Width="500px" TextMode="MultiLine" runat="server"></asp:TextBox> </ItemTemplate> <EditItemTemplate> <asp:TextBox id="EditActionItemTextBox" runat="server" Width="500px" TextMode="MultiLine"></asp:TextBox

Categories : Vb.Net

DataTable LoadDataRow vs ImportNewRow vs Rows.Add
as @Magnus suggested this is the faster way to populate the DataTable with new Rows nice and simple fewer lines of code Stopwatch SwSqlMdfLocalDb11 = new Stopwatch(); SwSqlMdfLocalDb11.Start(); NewDtForIns.BeginLoadData(); for (int i = 0; i < 1000000; i++) { NewDtForIns.LoadDataRow(new object[] { null, "NewShipperCompanyName", "NewShipperPhone" }, false); } NewDtForIns.EndLoadData(); DBRCL_SET.UpdateDBWithNewDtUsingSQLBulkCopy(NewDtForIns, tblClients._TblName); SwSqlMdfLocalDb11.Stop(); i will be happy to learn a new approach if there is one, although that's already some news for me... thanks.

Categories : C#

adding specific rows to new datatable
You can use Linq-to-DataSet: Dim filteredRows = From row In table Where row.Field(Of Int32)("Monday") = 10 _ OrElse row.Field(Of Int32)("Tuesday") = 50 table2 = filteredRows.CopyToDataTable() is there anyway doing this using loops, as this manually. using some sort of loop? of course: Dim table2 = table.Clone() For Each row As DataRow In table.Rows Dim monCount = row.Field(Of Int32)("Monday") Dim tueCount = row.Field(Of Int32)("Tuesday") If monCount = 10 OrElse tueCount = 50 Then Dim newRow = table2.Rows.Add() newRow.ItemArray = row.ItemArray End If Next

Categories : Dotnet

VB.NET-A way to insert rows into datagrid or datatable
If I understand your question which isn't very clear, the user is entering values that you want to query against rows in your database and if they exist, display some corresponding data or message. It sounds like what you want to do is bind your datagrid to a datasource, in my example an in-memory datatable, then intercept the data binding via DataGridView1.CellFormatting to compare/modify your data accordingly. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim sqlConnection As SqlConnection Dim sqlConnectionString As String = "YourConnectionString" Dim sqlDataAdapter As SqlDataAdapter Dim dataTable As New DataTable Dim sqlCommand As SqlCommand Dim sqlString As String Try sqlString = "SELECT * FROM YourTable" 'if u

Categories : Vb.Net

How to increment visible rows of p:datatable with p:outputLink
I have resolved my problem. Here is code: <h:form id="dataForm"> <p:dataTable value="#{tasks}" styleClass="dashTable" var="tasklar" rows="#{taskCriteria.pageSize}" lazy="true" selection="#{flowScope.selectedTask}" selectionMode="single" > <p:ajax event="rowSelect" /> <p:column headerText="#{messages.label_task_temasy}"> <h:outputText value="#{tasklar.taskTemasy}"/> </p:column> </p:dataTable> <p:commandLink style="float:left" update=":dataForm" action="#{taskCriteria.setPageSize(taskCriteria.pageSize+5)}"> <h:outputText value="Show more..." /> </p:commandLink> </h:form>

Categories : JSF

Expanded PrimeFaces's DataTable's rows misbehavior
As I stated in PrimeFaces forum: Expanded DataTable's rows misbehavior, In short, your code is working as (you) designed (it). :) I downloaded your code to my PC, changed your code, and i got the expected behavior working good. Added List availableColors to 'Car' /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rowexpansion; import java.util.List; public class Car implements java.io.Serializable { private static final long serialVersionUID = 2296448576778208049L; private String model; private String year; private String color; private List<Color> availableColors; public Car() { } public Car(String model, String year) { super(); this.model = model; this.year = year; }

Categories : JSF

Remove rows with same column value from DataTable and add corresponding values
This won't change your original DataTable: var table = dt.Copy().AsEnumerable() .GroupBy(row=>row["ITEM"]) .Select(g=> { DataRow dr = g.First(); dr.SetField("QTY", g.Sum(x=>x.Field<int>("QTY"))); return dr; }) .CopyToDataTable();

Categories : C#

How to split a string in a datatable and add into new rows using Linq C#?
LINQ can get you partway by allowing you to nest from clauses in queries (simplifying the output a bit): from DataListItem dli in PollDataList.Items let z = ... // as in existing code let y = ... let v = ... from checkbox in v.Items where checkbox.Selected select new [] { z.Value, checkbox.Value, "" } Here you will get an output item for each selected checkbox in each poll item (your Answered2). But you also want an output row for the Answered1 value for each poll item, and here LINQ is less helpful. There are two ways you can do this, the quick and ugly way using Enumerable.Concat: ... let v = ... from answer in new [] { y.SelectedValue }.Concat(v.Items.Where(r => r.Selected)) // http://msdn.microsoft.com/en-us/library/bb302894.aspx select new [] { z.Value, answer, "" } Or the cl

Categories : C#

How to highlight rows of extended datatable when mouse is over in jsf?
Using onrowmouseover and onrowmouseout worked fine on my end. Try using rowClass attribute of <rich:extendedDataTable> and define a rule in your stylesheet like so. .test:hover { background-color: yellow; } And do <rich:extendedDataTable rowClass="test"> Remember to set your <h:outputStylesheet> in <h:head>

Categories : Javascript

jQuery DataTable - Hide rows the intended way
DataTables offers this out of the box: DataTables individual column filtering example or, better still DataTables individual column filtering example (using select menus)

Categories : Javascript

Primefaces p:datatable adding and editing rows not working
Your code has some problems . But the problem I can see is here <!-- Add new document -dialog --> <p:dialog widgetVar="newDocumentDlg" id="newDocumentDialog" header="Add new document" message="Add new document" hideEffect="fade" showEffect="fade" resizable="true" closable="true" lazy="true" width="600"> <h:panelGrid columns="3"> <h:outputText value="Name" /> <p:spacer width="10" height="10" /> <p:inputText value="#{testMB.document.name}" width="35" maxlength="128" /> </h:panelGrid> You cannot set input text to current document name. Instead use another variable to hold value for new document name like private String newName; public String getNewName() { return newName; } publ

Categories : Java

Drag and drop of rows primefaces datatable/datagrid?
As far as i know from datatables (primefaces) in my applications, they have 2 main states/modes. It may be not the correct word but i stay with it. The 1st is display only, and 2nd editing. (In display i dont see events triggering so DnD wont work.) in editing they have a serious issue with selectivity. u have to press at the edge of the table and not in inline components reach to get the focus on the row. So The drop must be done in that area and only propably for events to trigger. If u see the examples...all drops are made on an outer component(panel etc) and the table is just updated because the ondrop event in ajax has run and changed the data the drop table will contain. That may be magic for incrementing data...but not for rearranging and updating cell or row data. SO the answer for

Categories : JSF

jQuery: Accessing table rows of second and further pages of a datatable
If you use an older version of jQuery you can use .live() function. With newer version you should switch to .on(). But you can always make a function from what you wrote: function example() { var testRows = $('#tbl').find('tbody').find('tr'); $this = $(this); testRows.each(function () { var description = $this.find('[id^="Desc"]').text(); descriptions.push(description); } } and run it every time you operate on your table: function removeTr() { $('tr').remove(); example(); }

Categories : Javascript

how can I send selected rows(with checkbox ) of datagridview to datatable?
Assuming that you know how to send a collection of DataGridViewRow objects, here is how you should only get those which are checked: var rows = yourDataGridView.Rows.Cast<DataGridViewRow>().Where(row => (bool) (row.Cells["name of checkbox column!"] as DataGridViewCheckBoxCell).Value); In case your DataGridView is databound, of course you should directly operate on the data isntead of juggling and casting around DataGridViewCells. Same as above without LINQ: var rows = new List<DataGridViewRow>(); foreach(DataGridViewRow row in yourDataGridView.Rows) if((bool)(row.Cells["name of checkbox column!"] as DataGridViewCheckBoxCell).Value) rows.Add(row);

Categories : C#

DataTable - Linq - select distinct rows based on grouping
When you use Group by in Linq you can get to the underlying items as an Enumberable. All you need to do is another Select to get just the values you want var rptTable = from t in ReportConfigurationTable.AsEnumerable() select new {Type = t["Type"], Product = t["Product"], Action = t["Action"], Quantity = t["Quantity"]}; var tableColumnGrouping = from table in rptTable group table by new { table.Type, table.Product } into groupedTable select new { tableColumn = groupedTable.Key, tableColumnCount = groupedTable.Count(), actions = g

Categories : C#

fast/efficient way to run a query in Access based on datatable rows?
You're thinking of an update query. You don't actually have to go over every row one by one. SQL is a set based language, so you only have to write a single statement that it should do for all rows. Do this: 1) Create > Query Design 2) Close the dialog that selects tables 3) Make sure you're in sql mode (top left corner) 4) Paste this: UPDATE INPUTTABLE INNER JOIN MDDB_MASTER ON INPUTTABLE.NDC = MDDB_MASTER.NDC SET INPUTTABLE.NDCDESC = [MDDB_MASTER].[NDC_DESC]; 5) Switch to design mode to see what happens. You may have to correct Input table, I couldn't find it's name. I'm assuming they;re both in the same database. You'll see the query type is now an update query. You can run this text through cmd.ExecuteNonQuery(sql) and the whole thing should run very quickly. If it doe

Categories : C#

Insert primefaces dataTable rows based on p:inputText fields
Try following Make List of Contact class as table value. In the actionListener method of commandButton, create new Contact class and set it's property with appropriate inputText. Append that newly created object to List In commandButton : process inputTexts, update Datatable Which will not required to store intermediate result into database

Categories : JSF

Change DataType for the DataColumn of DataTable after filling the data and updating the rows
If your queries consist only of equality comparisons then you can also encrypt the search criteria string e.g., When you are looking for users with DateOfBirth '1-1-2013' first encrypt this date and then search in the database. However, I think you might loose the purpose of encrypting data in the first place with this approach.

Categories : Asp Net

Bind GridView.ItemsSource back to DataTable but only visible columns and rows
if you want to have physical columns which are visible then you can directly iterate over datagrid columns collection like IEnumerable<DataGridColumn> visibleColumns = dataGrid.Columns.Where<DataGridColumn>(col => col.Visibility == System.Windows.Visibility.Visible); and then you can iterate over your DataTable records to get the value of field which has name equal to visibleColumn.Header.

Categories : Wpf



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.