Search Results

Search found 6257 results on 251 pages for 'columns'.

Page 33/251 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Should I comment Tables or Columns in my database?

    - by jako
    I like to comment my code with various information, and I think most people nowadays do so while writing some code. But when it comes to database tables or columns, I have never seen anyone setting some comments, and, to be honest, I don't even think of looking for comments there. So I am wondering if some people are commenting their DB strcuture here, and if I should bother commenting, for instance when I create a new column to an existing table?

    Read the article

  • How to get all rows but specifc columns from a DataTable?

    - by Oliver
    Currently i am having some problems with getting some data out of a DataTable by selecting all rows, but only some columns. To be a little more descriptive here is a little example: Sample Data | ID | FirstName | LastName | Age | +----+-----------+----------+-----+ | 1 | Alice | Wannabe | 22 | | 2 | Bob | Consumer | 27 | | 3 | Carol | Detector | 25 | What i have So what we got from our GUI is a IEnumerable<DataColumn> selectedColumns and there we'll find two elements (FirstName and LastName). Now i need some result which contains all rows, but only the above two columns (or any other list of selected columns). So far i already used LINQ on several one dimensional objects, but this two dimensional object gives me a little headache. // The hard-coded way Table.AsEnumerable().Select(row => new { FirstName = row[1], LastName = row[2] }); // The flexible way Table.AsEnumerable().Select(row => row ???) But how can i now say, which columns from row should be selected by using my selectedColumns?

    Read the article

  • Possible to Freeze Columns in a WPF ListView/GridView?

    - by Phil Sandler
    I currently have a GridView inside a ListView.View. The GridView columns will far exceed the width of the screen, so there will always be horizontal scrolling. What I would like to do is to have certain columns always remain on the screen regardless of scrolling. So the first x columns from the left are frozen (ala Excel), and the rest can scroll. It does not need to be dynamic/user selected--I know in advance which columns need to be frozen. Is this possible?

    Read the article

  • Sharepoint UpdateList Method : Newly created Columns are not visible.

    - by Pari
    Hi, I worked on code .It is working successfully. But Problem i am facing is: New Columns are not visible in List ( I tried with With Setting Required = "TRUE" ). I tried with compairing Field Value of Both Visible and No-Visible Columns. Difference i found is : Visible Columns (Created Manually) doesn't contain Version value. wereas columns i am creating have it. So i tried with passing null value to "ndVersion.Value". But it is still not working and automaticaly putting some value to version. Can you help me out in this? I tried Solution given Here . But it din't Worked again. :(

    Read the article

  • Can I combine values from multiple rows in another table into multiple columns of one row using SQL?

    - by Jordi
    I have two tables: T1: | M_ID | P_ID1 | P_ID2 | rest of T1 columns | | 0 | 0 | 1 | ... | | 1 | 2 | 3 | ... | T2: | P_ID | Type | A | B | | 0 | 1 | a | e | | 1 | 2 | b | f | | 2 | 1 | c | g | | 3 | 2 | d | h | Now, I want to have a query that selects this: | M_ID | P_1a | P_1b | P_2a | P_2b | rest of T1 columns | | 0 | a | e | b | f | ... | | 1 | c | g | c | h | ... | So, in words: I want to select all columns from T1, but I want to replace P_ID1 with the columns from T2, where the P_ID is equal to P_ID1, and the type is 1, and basically the same for P_ID2. I can obviously get the information I need with multiple queries, but I was wondering if there is a way that I can do this with one query. Any ideas? I'm currently using SQL Server 2008r2, but I'd also be interested in solutions for other database software. Thanks for the help!

    Read the article

  • Need a good way to store data in a DB from a table on a webpage that can have N columns.

    - by Abe Miessler
    Users need to be able to add a specific type of column to an otherwise static table on my web page and then save the information they enter in there to the database. I've been told that in reality they will almost never go over 5 columns but I would rather support N. The columns will all be of the same datatype. My first thought was to have an XML column with the values from all added columns in there but I was curious if anyone else had come up with a better solution. Suggestions?

    Read the article

  • Does the order of columns in a query matter?

    - by James Simpson
    When selecting columns from a MySQL table, is performance affected by the order that you select the columns as compared to their order in the table (not considering indexes that may cover the columns)? For example, you have a table with rows uid, name, bday, and you have the following query. SELECT uid, name, bday FROM table Does MySQL see the following query any differently and thus cause any sort of performance hit? SELECT uid, bday, name FROM table

    Read the article

  • to get columns from Excel files using Apache POI??

    - by posdef
    Hi, In order to do some statistical analysis I need to extract values in a column of an Excel sheet. I have been using the Apache POI package to read from Excel files, and it works fine when one needs to iterate over rows. However I couldn't find anything about getting columns neither in the API (link text) nor through google searching. As I need to get max and min values of different columns and generate random numbers using these values, so without picking up individual columns, the only other option is to iterate over rows and columns to get the values and compare one by one, which doesn't sound all that time-efficient. Any ideas on how to tackle this problem? Thanks,

    Read the article

  • zfdatagrid : how to set the relative order of columns?

    - by user522350
    To those of you who are familiar with zfdatagrid for the Zend framework: I got a recordset by a JOIN query, say from tables s and t, now I want to set the order in which the columns appear in the deployed table. For example, 5th column of table t to appear at the leftmost side, then 3rd column of table s, then 2nd column of table t, then 4th column of table s. How do I do this? Whatever I tried, it always shows first the columns of the left table of the JOIN, then the columns of the right table of the JOIN. I only know how to tell it which columns to show, but not their order. Thanks!

    Read the article

  • Indexed key vs indexed separate columns, which one is faster ?

    - by Jerry
    In MYSQL, from a pure performance perspective, if I have a table with large amount of data with 10/1 read/write ratio. is it faster in read/write performance to have 4 search criteria in separate columns and all indexed or have them combined in to one single string acting as a key and store in one indexed column ? e.g. say this table with 5 columns, first name, last name, sex, country and file where the first four columns will ALWAYS be given as a part of search parameters in a search or have a table with two columns, key and file. where the value of key can be john-smith-male-australia ?? I don't quite get the pros and cons. the point I try to stress is the fact that all parameters will be given.in a search.

    Read the article

  • JQuery data grid with sort, items, columns drag&drop. Is there any?

    - by Ole Jak
    JQuerry data grid with items&columns drag&drop, Items sort. Is there any? So I need Dragable\Dropable Items Drag and drop sorting of table columns Sort Items in columns You can taste how sweeet is Adobe Flex builder Data Grid and Its Drag-Drap here: http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/ Is there any JQuery analog?

    Read the article

  • Why do we need Audit Columns in Database Tables?

    - by Software Enthusiastic
    Hi I have seen many database designs having following audit columns on all the tables... Created By Create DateTime Updated By Upldated DateTime From one perspective I see tables from the following view... Entity Tables: Good candidate for Audit columns) Reference Tables: Audit columns may or may not required. In some case last update information is not at all required because record is never going to be modified.) Reference Data Tables Like Country Names, Entity State etc... Audit columns may not required because these information is created only during system installation time, and never going to be changed. I have seen many designers blindly put all audit columns to all tables, is this practice good, if yes what could be the reason... I just want to know because to me it seems illogical. It is difficult for me to figure out why do they design their db this way? I am not saying they are wrong or right, just want to know the WHY? You can also suggest me, if there is an alternative auditing patter or solution available... Thanks and Regards

    Read the article

  • How do I classify using GLCM and SVM Classifier in Matlab?

    - by Gomathi
    I'm on a project of liver tumor segmentation and classification. I used Region Growing and FCM for liver and tumor segmentation respectively. Then, I used Gray Level Co-occurence matrix for texture feature extraction. I have to use Support Vector Machine for Classification. But I don't know how to normalize the feature vectors. Can anyone tell how to program it in Matlab? To the GLCM program, I gave the tumor segmented image as input. Was I correct? If so, I think, then, my output will also be correct. My glcm coding, as far as I have tried is, I = imread('fzliver3.jpg'); GLCM = graycomatrix(I,'Offset',[2 0;0 2]); stats = graycoprops(GLCM,'all') t1= struct2array(stats) I2 = imread('fzliver4.jpg'); GLCM2 = graycomatrix(I2,'Offset',[2 0;0 2]); stats2 = graycoprops(GLCM2,'all') t2= struct2array(stats2) I3 = imread('fzliver5.jpg'); GLCM3 = graycomatrix(I3,'Offset',[2 0;0 2]); stats3 = graycoprops(GLCM3,'all') t3= struct2array(stats3) t=[t1;t2;t3] xmin = min(t); xmax = max(t); scale = xmax-xmin; tf=(x-xmin)/scale Was this a correct implementation? Also, I get an error at the last line. My output is: stats = Contrast: [0.0510 0.0503] Correlation: [0.9513 0.9519] Energy: [0.8988 0.8988] Homogeneity: [0.9930 0.9935] t1 = Columns 1 through 6 0.0510 0.0503 0.9513 0.9519 0.8988 0.8988 Columns 7 through 8 0.9930 0.9935 stats2 = Contrast: [0.0345 0.0339] Correlation: [0.8223 0.8255] Energy: [0.9616 0.9617] Homogeneity: [0.9957 0.9957] t2 = Columns 1 through 6 0.0345 0.0339 0.8223 0.8255 0.9616 0.9617 Columns 7 through 8 0.9957 0.9957 stats3 = Contrast: [0.0230 0.0246] Correlation: [0.7450 0.7270] Energy: [0.9815 0.9813] Homogeneity: [0.9971 0.9970] t3 = Columns 1 through 6 0.0230 0.0246 0.7450 0.7270 0.9815 0.9813 Columns 7 through 8 0.9971 0.9970 t = Columns 1 through 6 0.0510 0.0503 0.9513 0.9519 0.8988 0.8988 0.0345 0.0339 0.8223 0.8255 0.9616 0.9617 0.0230 0.0246 0.7450 0.7270 0.9815 0.9813 Columns 7 through 8 0.9930 0.9935 0.9957 0.9957 0.9971 0.9970 ??? Error using ==> minus Matrix dimensions must agree. The images are:

    Read the article

  • Ext.data.Store, Javascript Arrays and Ext.grid.ColumnModel

    - by Michael Wales
    I am using Ext.data.Store to call a PHP script which returns a JSON response with some metadata about fields that will be used in a query (unique name, table, field, and user-friendly title). I then loop through each of the Ext.data.Record objects, placing the data I need into an array (this_column), push that array onto the end of another array (columns), and eventually pass this to an Ext.grid.ColumnModel object. The problem I am having is - no matter which query I am testing against (I have a number of them, varying in size and complexity), the columns array always works as expected up to columns[15]. At columns[16], all indexes from that point and previous are filled with the value of columns[15]. This behavior continues until the loop reaches the end of the Ext.data.Store object, when the entire arrays consists of the same value. Here's some code: columns = []; this_column = []; var MetaData = Ext.data.Record.create([ {name: 'id'}, {name: 'table'}, {name: 'field'}, {name: 'title'} ]); // Query the server for metadata for the query we're about to run metaDataStore = new Ext.data.Store({ autoLoad: true, reader: new Ext.data.JsonReader({ totalProperty: 'results', root: 'fields', id: 'id' }, MetaData), proxy: new Ext.data.HttpProxy({ url: 'index.php/' + type + '/' + slug }), listeners: { 'load': function () { metaDataStore.each(function(r) { this_column['id'] = r.data['id']; this_column['header'] = r.data['title']; this_column['sortable'] = true; this_column['dataIndex'] = r.data['table'] + '.' + r.data['field']; // This display valid information, through the entire process console.info(this_column['id'] + ' : ' + this_column['header'] + ' : ' + this_column['sortable'] + ' : ' + this_column['dataIndex']); columns.push(this_column); }); // This goes nuts at columns[15] console.info(columns); gridColModel = new Ext.grid.ColumnModel({ columns: columns });

    Read the article

  • Flex AdvancedDataGrid - ColumnOrder With Formatter and ItemRenderer Question For Experts

    - by robin1126
    I have a advanceddatagrid that has around 15 columns. Some are string, some are numbers. I have shown 4 columns below. The number columns have formatting done for zero precision and 2 digits precision. The itemRenderer is just to show Blue Color if the number is +ve and Red Color if the number is -ve. It looks something like below ... I am trying to save the users setting of column order when he closes the application and reload with the same order when the user opens the applications. I am using SharedObjects and below is the code. for(var i:int=0; i< adgrid.columns.length;i++){ var columnObject:Object = new Object(); columnObject.columnDataField = adgrid.columns[i].dataField as String; columnObject.columnHeader =adgrid.columns[i].headerText as String; columnObject.width = adgrid.columns[i].width; columnArray.push(columnObject); } and then I save the columnArray to SharedObject. I retrive them using the below code for(var i:int=0;i adgrid.columns[i].dataField =columnArray[i].columnDataField; adgrid.columns[i].headerText =columnArray[i].columnHeader; adgrid.columns[i].width = columnArray[i].width; } How can I save and reload the Formatter and ItemRenderer data . I am having trouble saving the formatter and itemrenderer and reloading it again. I would really appreciate if you can shown the code. How can I reshuffle the columns but can preserve all the properties of it to the sharedobject and recover it again.

    Read the article

  • Why do Core Data sqlite table columns start with 'Z'?

    - by Dia
    I was looking at the sqlite table that Core Data generates and noticed that all table columns start with 'Z'. I realize this is an implementation detail, but I was curious as to why that's the case and if there was a design decision involved in this. Anyone happen to know or guess why? Here's a sample schema output of Core Data sqlite database: sqlite .schema CREATE TABLE ZPOST ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZPOSTID INTEGER, ZUSER INTEGER, ZCREATEDAT TIMESTAMP, ZTEXT VARCHAR ); CREATE TABLE ZUSER ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZUSERID INTEGER, ZAVATARIMAGEURLSTRING VARCHAR, ZUSERNAME VARCHAR ); CREATE TABLE Z_METADATA (Z_VERSION INTEGER PRIMARY KEY, Z_UUID VARCHAR(255), Z_PLIST BLOB); CREATE TABLE Z_PRIMARYKEY (Z_ENT INTEGER PRIMARY KEY, Z_NAME VARCHAR, Z_SUPER INTEGER, Z_MAX INTEGER);

    Read the article

  • How can I turn off calculated columns in an Excel table from a macro using VBA? [migrated]

    - by user41293
    I am working on a macro that inserts formulas into a cell in an Excel table. The Excel table does the automatic filling of columns and fills all the cells in that column with the formula, but all I want is one cell to have the formula. I cannot just turn off automatic formula for tables as I need to have other people use this worksheet on their systems. Is there a way to turn off the automatic filling of formulas in a table using VBA in a macro? It just needs to be temporary: I just want to turn it off, put in my formulas, then turn it back on.

    Read the article

  • datagrid binding

    - by abcdd007
    using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class OrderMaster : System.Web.UI.Page { BLLOrderMaster objMaster = new BLLOrderMaster(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SetInitialRow(); string OrderNumber = objMaster.SelectDetails().ToString(); if (OrderNumber != "") { txtOrderNo.Text = OrderNumber.ToString(); txtOrderDate.Focus(); } } } private void InsertEmptyRow() { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("ItemCode", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("Unit", typeof(string))); dt.Columns.Add(new DataColumn("Qty", typeof(string))); dt.Columns.Add(new DataColumn("Rate", typeof(string))); dt.Columns.Add(new DataColumn("Disc", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); for (int i = 0; i < 5; i++) { dr = dt.NewRow(); dr["ItemCode"] = string.Empty; dr["Description"] = string.Empty; dr["Unit"] = string.Empty; dr["Qty"] = string.Empty; dr["Rate"] = string.Empty; dr["Disc"] = string.Empty; dr["Amount"] = string.Empty; dt.Rows.Add(dr); } //GridView1.DataSource = dt; //GridView1.DataBind(); } private void SetInitialRow() { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("RowNumber", typeof(string))); dt.Columns.Add(new DataColumn("ItemCode", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("Unit", typeof(string))); dt.Columns.Add(new DataColumn("Qty", typeof(string))); dt.Columns.Add(new DataColumn("Rate", typeof(string))); dt.Columns.Add(new DataColumn("Disc", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); dr = dt.NewRow(); dr["RowNumber"] = 1; dr["ItemCode"] = string.Empty; dr["Description"] = string.Empty; dr["Unit"] = string.Empty; dr["Qty"] = string.Empty; dr["Rate"] = string.Empty; dr["Disc"] = string.Empty; dr["Amount"] = string.Empty; dt.Rows.Add(dr); //Store DataTable ViewState["OrderDetails"] = dt; Gridview1.DataSource = dt; Gridview1.DataBind(); } protected void AddNewRowToGrid() { int rowIndex = 0; if (ViewState["OrderDetails"] != null) { DataTable dtCurrentTable = (DataTable)ViewState["OrderDetails"]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the TextBox values TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txtItemCode"); TextBox box2 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txtdescription"); TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txtunit"); TextBox box4 = (TextBox)Gridview1.Rows[rowIndex].Cells[4].FindControl("txtqty"); TextBox box5 = (TextBox)Gridview1.Rows[rowIndex].Cells[5].FindControl("txtRate"); TextBox box6 = (TextBox)Gridview1.Rows[rowIndex].Cells[6].FindControl("txtdisc"); TextBox box7 = (TextBox)Gridview1.Rows[rowIndex].Cells[7].FindControl("txtamount"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["RowNumber"] = i + 1; drCurrentRow["ItemCode"] = box1.Text; drCurrentRow["Description"] = box2.Text; drCurrentRow["Unit"] = box3.Text; drCurrentRow["Qty"] = box4.Text; drCurrentRow["Rate"] = box5.Text; drCurrentRow["Disc"] = box6.Text; drCurrentRow["Amount"] = box7.Text; rowIndex++; } //add new row to DataTable dtCurrentTable.Rows.Add(drCurrentRow); //Store the current data to ViewState ViewState["OrderDetails"] = dtCurrentTable; //Rebind the Grid with the current data Gridview1.DataSource = dtCurrentTable; Gridview1.DataBind(); } } else { // } //Set Previous Data on Postbacks SetPreviousData(); } private void SetPreviousData() { int rowIndex = 0; if (ViewState["OrderDetails"] != null) { DataTable dt = (DataTable)ViewState["OrderDetails"]; if (dt.Rows.Count > 0) { for (int i = 1; i < dt.Rows.Count; i++) { TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txtItemCode"); TextBox box2 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txtdescription"); TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txtunit"); TextBox box4 = (TextBox)Gridview1.Rows[rowIndex].Cells[4].FindControl("txtqty"); TextBox box5 = (TextBox)Gridview1.Rows[rowIndex].Cells[5].FindControl("txtRate"); TextBox box6 = (TextBox)Gridview1.Rows[rowIndex].Cells[6].FindControl("txtdisc"); TextBox box7 = (TextBox)Gridview1.Rows[rowIndex].Cells[7].FindControl("txtamount"); box1.Text = dt.Rows[i]["ItemCode"].ToString(); box2.Text = dt.Rows[i]["Description"].ToString(); box3.Text = dt.Rows[i]["Unit"].ToString(); box4.Text = dt.Rows[i]["Qty"].ToString(); box5.Text = dt.Rows[i]["Rate"].ToString(); box6.Text = dt.Rows[i]["Disc"].ToString(); box7.Text = dt.Rows[i]["Amount"].ToString(); rowIndex++; } dt.AcceptChanges(); } ViewState["OrderDetails"] = dt; } } protected void BindOrderDetails() { DataTable dtOrderDetails = new DataTable(); if (ViewState["OrderDetails"] != null) { dtOrderDetails = (DataTable)ViewState["OrderDetails"]; } else { dtOrderDetails.Columns.Add(""); dtOrderDetails.Columns.Add(""); dtOrderDetails.Columns.Add(""); dtOrderDetails.Columns.Add(""); dtOrderDetails.Columns.Add(""); dtOrderDetails.Columns.Add(""); dtOrderDetails.AcceptChanges(); DataRow dr = dtOrderDetails.NewRow(); dtOrderDetails.Rows.Add(dr); ViewState["OrderDetails"] = dtOrderDetails; } if (dtOrderDetails != null) { Gridview1.DataSource = dtOrderDetails; Gridview1.DataBind(); if (Gridview1.Rows.Count > 0) { ((LinkButton)Gridview1.Rows[Gridview1.Rows.Count - 1].FindControl("btnDelete")).Visible = false; } } } protected void btnSave_Click(object sender, EventArgs e) { if (txtOrderDate.Text != "" && txtOrderNo.Text != "" && txtPartyName.Text != "" && txttotalAmount.Text !="") { BLLOrderMaster bllobj = new BLLOrderMaster(); DataTable dtdetails = new DataTable(); UpdateItemDetailRow(); dtdetails = (DataTable)ViewState["OrderDetails"]; SetValues(bllobj); int k = 0; k = bllobj.Insert_Update_Delete(1, bllobj, dtdetails); if (k > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Login Denied", "<Script>alert('Order Code Alraddy Exist');</Script>", false); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Login Denied", "<Script>alert('Record Saved Successfully');</Script>", false); } dtdetails.Clear(); SetInitialRow(); txttotalAmount.Text = ""; txtOrderNo.Text = ""; txtPartyName.Text = ""; txtOrderDate.Text = ""; txttotalQty.Text = ""; string OrderNumber = objMaster.SelectDetails().ToString(); if (OrderNumber != "") { txtOrderNo.Text = OrderNumber.ToString(); txtOrderDate.Focus(); } } else { txtOrderNo.Text = ""; } } public void SetValues(BLLOrderMaster bllobj) { if (txtOrderNo.Text != null && txtOrderNo.Text.ToString() != "") { bllobj.OrNumber = Convert.ToInt16(txtOrderNo.Text); } if (txtOrderDate.Text != null && txtOrderDate.Text.ToString() != "") { bllobj.Date = DateTime.Parse(txtOrderDate.Text.ToString()).ToString("dd/MM/yyyy"); } if (txtPartyName.Text != null && txtPartyName.Text.ToString() != "") { bllobj.PartyName = txtPartyName.Text; } bllobj.TotalBillAmount = txttotalAmount.Text == "" ? 0 : int.Parse(txttotalAmount.Text); bllobj.TotalQty = txttotalQty.Text == "" ? 0 : int.Parse(txttotalQty.Text); } protected void txtdisc_TextChanged(object sender, EventArgs e) { double total = 0; double totalqty = 0; foreach (GridViewRow dgvr in Gridview1.Rows) { TextBox tb = (TextBox)dgvr.Cells[7].FindControl("txtamount"); double sum; if (double.TryParse(tb.Text.Trim(), out sum)) { total += sum; } TextBox tb1 = (TextBox)dgvr.Cells[4].FindControl("txtqty"); double qtysum; if (double.TryParse(tb1.Text.Trim(), out qtysum)) { totalqty += qtysum; } } txttotalAmount.Text = total.ToString(); txttotalQty.Text = totalqty.ToString(); AddNewRowToGrid(); Gridview1.TabIndex = 1; } public void UpdateItemDetailRow() { DataTable dt = new DataTable(); if (ViewState["OrderDetails"] != null) { dt = (DataTable)ViewState["OrderDetails"]; } if (dt.Rows.Count > 0) { for (int i = 0; i < Gridview1.Rows.Count; i++) { dt.Rows[i]["ItemCode"] = (Gridview1.Rows[i].FindControl("txtItemCode") as TextBox).Text.ToString(); if (dt.Rows[i]["ItemCode"].ToString() == "") { dt.Rows[i].Delete(); break; } else { dt.Rows[i]["Description"] = (Gridview1.Rows[i].FindControl("txtdescription") as TextBox).Text.ToString(); dt.Rows[i]["Unit"] = (Gridview1.Rows[i].FindControl("txtunit") as TextBox).Text.ToString(); dt.Rows[i]["Qty"] = (Gridview1.Rows[i].FindControl("txtqty") as TextBox).Text.ToString(); dt.Rows[i]["Rate"] = (Gridview1.Rows[i].FindControl("txtRate") as TextBox).Text.ToString(); dt.Rows[i]["Disc"] = (Gridview1.Rows[i].FindControl("txtdisc") as TextBox).Text.ToString(); dt.Rows[i]["Amount"] = (Gridview1.Rows[i].FindControl("txtamount") as TextBox).Text.ToString(); } } dt.AcceptChanges(); } ViewState["OrderDetails"] = dt; } }

    Read the article

  • Run Reporting Service in local mode and generate columns automatically?

    - by grady
    Hi, I have a SQL query right now which I want to use with the MS reporting services in my ASP.NET application. So I created a report in local mode (rdlc) and attached this to a report viewer. Since my query uses parameters, I created a stored procedure, which had exactly those parameters. In addition to that I had some textboxes which are used for entering the params for the query and a button to call the stored proc and to fill the datatset which is bound to the report viewer. This works, I press the button and according to what I entred the correct data is shown. Now my question: In the future I plan to have multiple reports (which will be selected in a dropdown) and I wonder if I can somehow just call the correct stored procedure and according to the columns which are *SELECT*ed in the procedure, the columns are shown in the report. Example: I select report1 from the dropdown (procedure for report 1 is called), 5 columns are shown in the reportviewer. I select report2 from dropdown (procedure for report 2 is called), 8 columns are shown. Is that possible somehow? Thanks :-)

    Read the article

  • Beware Sneaky Reads with Unique Indexes

    - by Paul White NZ
    A few days ago, Sandra Mueller (twitter | blog) asked a question using twitter’s #sqlhelp hash tag: “Might SQL Server retrieve (out-of-row) LOB data from a table, even if the column isn’t referenced in the query?” Leaving aside trivial cases (like selecting a computed column that does reference the LOB data), one might be tempted to say that no, SQL Server does not read data you haven’t asked for.  In general, that’s quite correct; however there are cases where SQL Server might sneakily retrieve a LOB column… Example Table Here’s a T-SQL script to create that table and populate it with 1,000 rows: CREATE TABLE dbo.LOBtest ( pk INTEGER IDENTITY NOT NULL, some_value INTEGER NULL, lob_data VARCHAR(MAX) NULL, another_column CHAR(5) NULL, CONSTRAINT [PK dbo.LOBtest pk] PRIMARY KEY CLUSTERED (pk ASC) ); GO DECLARE @Data VARCHAR(MAX); SET @Data = REPLICATE(CONVERT(VARCHAR(MAX), 'x'), 65540);   WITH Numbers (n) AS ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 0)) FROM master.sys.columns C1, master.sys.columns C2 ) INSERT LOBtest WITH (TABLOCKX) ( some_value, lob_data ) SELECT TOP (1000) N.n, @Data FROM Numbers N WHERE N.n <= 1000; Test 1: A Simple Update Let’s run a query to subtract one from every value in the some_value column: UPDATE dbo.LOBtest WITH (TABLOCKX) SET some_value = some_value - 1; As you might expect, modifying this integer column in 1,000 rows doesn’t take very long, or use many resources.  The STATITICS IO and TIME output shows a total of 9 logical reads, and 25ms elapsed time.  The query plan is also very simple: Looking at the Clustered Index Scan, we can see that SQL Server only retrieves the pk and some_value columns during the scan: The pk column is needed by the Clustered Index Update operator to uniquely identify the row that is being changed.  The some_value column is used by the Compute Scalar to calculate the new value.  (In case you are wondering what the Top operator is for, it is used to enforce SET ROWCOUNT). Test 2: Simple Update with an Index Now let’s create a nonclustered index keyed on the some_value column, with lob_data as an included column: CREATE NONCLUSTERED INDEX [IX dbo.LOBtest some_value (lob_data)] ON dbo.LOBtest (some_value) INCLUDE ( lob_data ) WITH ( FILLFACTOR = 100, MAXDOP = 1, SORT_IN_TEMPDB = ON ); This is not a useful index for our simple update query; imagine that someone else created it for a different purpose.  Let’s run our update query again: UPDATE dbo.LOBtest WITH (TABLOCKX) SET some_value = some_value - 1; We find that it now requires 4,014 logical reads and the elapsed query time has increased to around 100ms.  The extra logical reads (4 per row) are an expected consequence of maintaining the nonclustered index. The query plan is very similar to before (click to enlarge): The Clustered Index Update operator picks up the extra work of maintaining the nonclustered index. The new Compute Scalar operators detect whether the value in the some_value column has actually been changed by the update.  SQL Server may be able to skip maintaining the nonclustered index if the value hasn’t changed (see my previous post on non-updating updates for details).  Our simple query does change the value of some_data in every row, so this optimization doesn’t add any value in this specific case. The output list of columns from the Clustered Index Scan hasn’t changed from the one shown previously: SQL Server still just reads the pk and some_data columns.  Cool. Overall then, adding the nonclustered index hasn’t had any startling effects, and the LOB column data still isn’t being read from the table.  Let’s see what happens if we make the nonclustered index unique. Test 3: Simple Update with a Unique Index Here’s the script to create a new unique index, and drop the old one: CREATE UNIQUE NONCLUSTERED INDEX [UQ dbo.LOBtest some_value (lob_data)] ON dbo.LOBtest (some_value) INCLUDE ( lob_data ) WITH ( FILLFACTOR = 100, MAXDOP = 1, SORT_IN_TEMPDB = ON ); GO DROP INDEX [IX dbo.LOBtest some_value (lob_data)] ON dbo.LOBtest; Remember that SQL Server only enforces uniqueness on index keys (the some_data column).  The lob_data column is simply stored at the leaf-level of the non-clustered index.  With that in mind, we might expect this change to make very little difference.  Let’s see: UPDATE dbo.LOBtest WITH (TABLOCKX) SET some_value = some_value - 1; Whoa!  Now look at the elapsed time and logical reads: Scan count 1, logical reads 2016, physical reads 0, read-ahead reads 0, lob logical reads 36015, lob physical reads 0, lob read-ahead reads 15992.   CPU time = 172 ms, elapsed time = 16172 ms. Even with all the data and index pages in memory, the query took over 16 seconds to update just 1,000 rows, performing over 52,000 LOB logical reads (nearly 16,000 of those using read-ahead). Why on earth is SQL Server reading LOB data in a query that only updates a single integer column? The Query Plan The query plan for test 3 looks a bit more complex than before: In fact, the bottom level is exactly the same as we saw with the non-unique index.  The top level has heaps of new stuff though, which I’ll come to in a moment. You might be expecting to find that the Clustered Index Scan is now reading the lob_data column (for some reason).  After all, we need to explain where all the LOB logical reads are coming from.  Sadly, when we look at the properties of the Clustered Index Scan, we see exactly the same as before: SQL Server is still only reading the pk and some_value columns – so what’s doing the LOB reads? Updates that Sneakily Read Data We have to go as far as the Clustered Index Update operator before we see LOB data in the output list: [Expr1020] is a bit flag added by an earlier Compute Scalar.  It is set true if the some_value column has not been changed (part of the non-updating updates optimization I mentioned earlier). The Clustered Index Update operator adds two new columns: the lob_data column, and some_value_OLD.  The some_value_OLD column, as the name suggests, is the pre-update value of the some_value column.  At this point, the clustered index has already been updated with the new value, but we haven’t touched the nonclustered index yet. An interesting observation here is that the Clustered Index Update operator can read a column into the data flow as part of its update operation.  SQL Server could have read the LOB data as part of the initial Clustered Index Scan, but that would mean carrying the data through all the operations that occur prior to the Clustered Index Update.  The server knows it will have to go back to the clustered index row to update it, so it delays reading the LOB data until then.  Sneaky! Why the LOB Data Is Needed This is all very interesting (I hope), but why is SQL Server reading the LOB data?  For that matter, why does it need to pass the pre-update value of the some_value column out of the Clustered Index Update? The answer relates to the top row of the query plan for test 3.  I’ll reproduce it here for convenience: Notice that this is a wide (per-index) update plan.  SQL Server used a narrow (per-row) update plan in test 2, where the Clustered Index Update took care of maintaining the nonclustered index too.  I’ll talk more about this difference shortly. The Split/Sort/Collapse combination is an optimization, which aims to make per-index update plans more efficient.  It does this by breaking each update into a delete/insert pair, reordering the operations, removing any redundant operations, and finally applying the net effect of all the changes to the nonclustered index. Imagine we had a unique index which currently holds three rows with the values 1, 2, and 3.  If we run a query that adds 1 to each row value, we would end up with values 2, 3, and 4.  The net effect of all the changes is the same as if we simply deleted the value 1, and added a new value 4. By applying net changes, SQL Server can also avoid false unique-key violations.  If we tried to immediately update the value 1 to a 2, it would conflict with the existing value 2 (which would soon be updated to 3 of course) and the query would fail.  You might argue that SQL Server could avoid the uniqueness violation by starting with the highest value (3) and working down.  That’s fine, but it’s not possible to generalize this logic to work with every possible update query. SQL Server has to use a wide update plan if it sees any risk of false uniqueness violations.  It’s worth noting that the logic SQL Server uses to detect whether these violations are possible has definite limits.  As a result, you will often receive a wide update plan, even when you can see that no violations are possible. Another benefit of this optimization is that it includes a sort on the index key as part of its work.  Processing the index changes in index key order promotes sequential I/O against the nonclustered index. A side-effect of all this is that the net changes might include one or more inserts.  In order to insert a new row in the index, SQL Server obviously needs all the columns – the key column and the included LOB column.  This is the reason SQL Server reads the LOB data as part of the Clustered Index Update. In addition, the some_value_OLD column is required by the Split operator (it turns updates into delete/insert pairs).  In order to generate the correct index key delete operation, it needs the old key value. The irony is that in this case the Split/Sort/Collapse optimization is anything but.  Reading all that LOB data is extremely expensive, so it is sad that the current version of SQL Server has no way to avoid it. Finally, for completeness, I should mention that the Filter operator is there to filter out the non-updating updates. Beating the Set-Based Update with a Cursor One situation where SQL Server can see that false unique-key violations aren’t possible is where it can guarantee that only one row is being updated.  Armed with this knowledge, we can write a cursor (or the WHILE-loop equivalent) that updates one row at a time, and so avoids reading the LOB data: SET NOCOUNT ON; SET STATISTICS XML, IO, TIME OFF;   DECLARE @PK INTEGER, @StartTime DATETIME; SET @StartTime = GETUTCDATE();   DECLARE curUpdate CURSOR LOCAL FORWARD_ONLY KEYSET SCROLL_LOCKS FOR SELECT L.pk FROM LOBtest L ORDER BY L.pk ASC;   OPEN curUpdate;   WHILE (1 = 1) BEGIN FETCH NEXT FROM curUpdate INTO @PK;   IF @@FETCH_STATUS = -1 BREAK; IF @@FETCH_STATUS = -2 CONTINUE;   UPDATE dbo.LOBtest SET some_value = some_value - 1 WHERE CURRENT OF curUpdate; END;   CLOSE curUpdate; DEALLOCATE curUpdate;   SELECT DATEDIFF(MILLISECOND, @StartTime, GETUTCDATE()); That completes the update in 1280 milliseconds (remember test 3 took over 16 seconds!) I used the WHERE CURRENT OF syntax there and a KEYSET cursor, just for the fun of it.  One could just as well use a WHERE clause that specified the primary key value instead. Clustered Indexes A clustered index is the ultimate index with included columns: all non-key columns are included columns in a clustered index.  Let’s re-create the test table and data with an updatable primary key, and without any non-clustered indexes: IF OBJECT_ID(N'dbo.LOBtest', N'U') IS NOT NULL DROP TABLE dbo.LOBtest; GO CREATE TABLE dbo.LOBtest ( pk INTEGER NOT NULL, some_value INTEGER NULL, lob_data VARCHAR(MAX) NULL, another_column CHAR(5) NULL, CONSTRAINT [PK dbo.LOBtest pk] PRIMARY KEY CLUSTERED (pk ASC) ); GO DECLARE @Data VARCHAR(MAX); SET @Data = REPLICATE(CONVERT(VARCHAR(MAX), 'x'), 65540);   WITH Numbers (n) AS ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 0)) FROM master.sys.columns C1, master.sys.columns C2 ) INSERT LOBtest WITH (TABLOCKX) ( pk, some_value, lob_data ) SELECT TOP (1000) N.n, N.n, @Data FROM Numbers N WHERE N.n <= 1000; Now here’s a query to modify the cluster keys: UPDATE dbo.LOBtest SET pk = pk + 1; The query plan is: As you can see, the Split/Sort/Collapse optimization is present, and we also gain an Eager Table Spool, for Halloween protection.  In addition, SQL Server now has no choice but to read the LOB data in the Clustered Index Scan: The performance is not great, as you might expect (even though there is no non-clustered index to maintain): Table 'LOBtest'. Scan count 1, logical reads 2011, physical reads 0, read-ahead reads 0, lob logical reads 36015, lob physical reads 0, lob read-ahead reads 15992.   Table 'Worktable'. Scan count 1, logical reads 2040, physical reads 0, read-ahead reads 0, lob logical reads 34000, lob physical reads 0, lob read-ahead reads 8000.   SQL Server Execution Times: CPU time = 483 ms, elapsed time = 17884 ms. Notice how the LOB data is read twice: once from the Clustered Index Scan, and again from the work table in tempdb used by the Eager Spool. If you try the same test with a non-unique clustered index (rather than a primary key), you’ll get a much more efficient plan that just passes the cluster key (including uniqueifier) around (no LOB data or other non-key columns): A unique non-clustered index (on a heap) works well too: Both those queries complete in a few tens of milliseconds, with no LOB reads, and just a few thousand logical reads.  (In fact the heap is rather more efficient). There are lots more fun combinations to try that I don’t have space for here. Final Thoughts The behaviour shown in this post is not limited to LOB data by any means.  If the conditions are met, any unique index that has included columns can produce similar behaviour – something to bear in mind when adding large INCLUDE columns to achieve covering queries, perhaps. Paul White Email: [email protected] Twitter: @PaulWhiteNZ

    Read the article

  • I want to move columns in a gradebook based on the column header title to another gradebook

    - by Pat
    I have to average grades based on each objective for a new report card we have to complete this year. For example Column one has students names, each additional column will have the objective associated with the assignment. I would like to move the entire column to another sheet for each objective. Is there a formula or macro that will do that. For example objective 3.1A is in columns 2, 5, and 7, objective 3.2B is located in columns 1, 4, 10, and 12, objective 3.4c is in column 3, 6, 9, and 11. I would like to have a spreadsheet for each objective.

    Read the article

  • How can I do two columns in OpenOffice.org Writer?

    - by Sanoj
    I would like to structure my document with two columns in the middle of the page, and one column in the top and in the bottom. Like my example below. How can I do two columns like this in OpenOffice.org Writer? My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document My document

    Read the article

  • Excel; exporting/importing different columns to different csv files

    - by Sisyphus
    Is there a way to batch export different columns to different csv files in excel on an OSX, I'm thinking something along the lines of possibly automator, applescript or bash. I've had a look play around with automator and so far no look. The best I have accomplished export the whole sheet, then use sed to strip out what I don't need, however this is terribly inefficient. Also, is there a method, to batch import multiple csv files into columns. Thanks in advance && sorry I didn't tag excel correctly it wouldn't allow me to create the excel:mac tag

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >