Is there a way to add a column after a filled DataTable from SQL with the same rows?

My problem is that not to add rows like filled by SQLDataAdapter at the same row in DataGridView. How to make that? I showed below the details with my code also a screen shot, which shows the rows differences from the origin one.
I don't want to add an expression as column behave in my sql script to get what I need with query result. I don't want to obtain that way.
using (SqlConnection c = new SqlConnection(ConnStrMSSQL))
c.Open();
// 2
// Create new DataAdapter
using (SqlDataAdapter a = new SqlDataAdapter("SELECT SIPNO, SERINO, TARIH FROM SNOHAREKETLER WHERE Cast(TARIH as DATE) BETWEEN '2015/03/20' AND '2015/03/20' AND (TEZNO = 'T23' OR TEZNO = 'T31') AND CIKTI is null", c))
// 3
// Use DataAdapter to fill DataTable
DataTable t = new DataTable();
a.Fill(t);
t.Columns.Add("MyColumn", typeof(string));
DataRow workRow;
int iGetCount = t.Rows.Count;
for (int i = 0; i <= iGetCount - 1; i++)
workRow = t.NewRow();
workRow["MyColumn"] = i;
t.Rows.Add(workRow);
dataGridView1.DataSource = t;

The extra column isn't applied to only certain rows.  The columns of a table identify what data each row will contain.  Hence adding a column to the table automatically adds them to the rows.  What you're seeing is that all the initial rows
aren't being assigned a value so they retain their default value of null.  Later you enumerate the rows of the existing table and call AddRow which adds new rows.  This isn't adding columns, but rows.
To generate values for the existing rows you should ideally simply pass the data back from the database.  DT computed columns can be difficult to set up as it is limited to what it can do.  If you want to use a computed column on the Datatable
itself then define the column as a computed column and every row will calculate its own value.
DataTable data = GetData();
//Add elapsed time column
var col = new DataColumn("ElapsedTime", typeof(TimeSpan), "expr");
data.Columns.Add(col);
dataGridView1.DataSource = data;
The issue you will run into however is that calculating a diff on DateTime doesn't work in a computed column as the expression doesn't support the necessary functions.  You can google for how people solved this if you are interested in alternatives. 
Most people just tend to add the column and then hook into the various change events to update the value as needed.

Similar Messages

  • HT204074 I went to buy a song on iTunes and it said I have already purchased this item, but it's not in my library. Is there a way to populate songs that I have downloaded on past computers with the same apple ID?

    I went to buy a song on iTunes and it said I have already purchased this item, but it's not in my library. Is there a way to populate songs that I have downloaded on past computers with the same apple ID?

    If iCloud is available for your country, you should. Here is the article that has the steps on how you can do this:
    http://support.apple.com/kb/HT2519

  • Is there any way to add a fade gradient to a rectangle I made with the title editor?

    I made a rectangle as a background with the title editor.
    I want to make the sides fade out to nothing, sort of like a glow in PS...
    Is there any way to do that?
    I tried using a stroke, and a gradient, but I didn't see a way to select no color.
    Any ideas?

    Ann,
    Neat! You always come up with some great tricks.
    Now, I am not clear on this part, so some "hand-holding" will be necessary:
    Make it the size of the action safe margin, so it is slightly smaller than the framesize.
    Can you give me a bit more detail, please?
    I did the Fast Blur @ 60 and checked Blur Dimensions to Horizontal and it gave me a nice gradient.
    I just think that I am missing something, regarding the Action Safe Margins.
    Thanks for the tip, as always,
    Hunt
    [Edit] It might have just dawned on me. You are limiting one side of the rectangle WITH the Action Safe Margin. Is that correct? That would give one the rectangle coming in solid from outside the Frame and then "fading" on the end that we can see.
    Message was edited by: the_wine_snob - Added [Edit]

  • We each have our own device, a laptop and an iPad.  when sending imessages recipients cannot tell which of us sent it other than looking at the content.  Is there any way to add an identifier to make it clear who is sending the message?

    We each have our own device, a laptop and an iPad.  when sending imessages recipients cannot tell which of us sent it other than looking at the content.  Is there any way to add an identifier to make it clear who is sending the message?  I know we can say 'this is mom or this is dad" but when an email is sent it identifies the device that sent it so why not imessages too? 

    Stop using the same apple id on all your devices. Each person should have their own. You can still share apps via home sharing.

  • I would like to know if there a way to use window (via bootcamp) and use a dual screen with the use of thunderbolt?

    I would like to know if there a way to use window (via bootcamp) and use a dual screen with the use of thunderbolt?

    There are very specific requirements for using an iMac as an external display.
    From Target Display Mode: Frequently Asked Questions (FAQ) - Apple Support
    What are the requirements for TDM?
    A Mac notebook or desktop with a Mini DisplayPort or Thunderbolt connection
    A Thunderbolt or Mini DisplayPort cable
    A supported iMac with OS X 10.6.1 or later. The table below shows iMac computers that support TDM, the required cables, and the port of the computer to which you are connecting the iMac.
    iMac Model
    Cable Supported
    Port on Source Computer
    iMac (27-inch Late 2009)
    Mini DisplayPort to Mini DisplayPort
    Mini DisplayPort or Thunderbolt
    iMac (27-inch Mid 2010)
    Mini DisplayPort to Mini DisplayPort
    Mini DisplayPort or Thunderbolt
    iMac (Mid 2011)
    Thunderbolt to Thunderbolt
    Thunderbolt
    iMac (Mid 2012 and later)
    Thunderbolt to Thunderbolt
    Thunderbolt
    Note that the iMac (Retina 5K, 27-inch, Late 2014) does not support Target Display Mode.

  • Is there a way to add a column in a measurement file?

    Hello,
    Suppose I take several measurements from 3 channels (at the same time) and they all get saved in a text (.LVM) file using the "Write to Measurement File" method.
    For ex (note that I left the second column empty (with zero's) on purpose):
    X_Value    Untitled    Untitled 1    Untitled 2    Untitled 3    Comment
    0.000000    0.000000    1.000000    2.000000    4.000000
    1.000000    0.000000    1.100000    0.200000    0.500000
    2.000000    0.000000    1.250000    2.100000    1.300000
    . (etc)...
    ...and later (in another VI) you retrieve this information, do some calculations  and want to save this new data in the same file.
    For ex:
    X_Value    Untitled    Untitled 1    Untitled 2    Untitled 3    Comment
    0.000000    1.245000    1.000000    2.000000    4.000000
    1.000000    0.304000    1.100000    0.200000    0.500000
    2.000000    3.340000    1.250000    2.100000    1.300000
    ...so that now the second column has the calculated data
    Is that possible?
    (and how?)
    Thanks!

    Since you already have zeroes in the file, the space and reserved and it is possible to do what you want to do (it would also be possible without the zeroes, but more work).  It will be very slow.  Before you start, you may want to read the LVM specification.  The general idea is the following:
    Find the start of your data.  You can do this by searching for the "***End_of_Header**" tags.  Depending on your file, there will be one or two before your data starts.  After the End_of_Header, the next line is your column headers, the next your data.  Position the file pointer at the beginning of the first line so you can start to process the file a line at a time.
    Read in one line.
    Find the position of the first tab in the string and add one.
    Move your file pointer this many bytes forward in the file.
    Write your new value (be careful to use the correct number of digits)
    Move your file pointer to the head of the next line (you can calculate this each time, but it will be a fixed number based on how many columns you have left).
    Repeat 2 - 6 until you hit the end of the file.
    If you need help with any of the steps, let us know.  The string and file I/O palettes should have all the functionality you need.
    Message Edited by DFGray on 02-22-2008 07:17 AM
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Is there a way to have 2 separate icloud accounts posting photos and contacts to the same central repository?

    My wife and I have iPhone 4S's but are currently sharing the same iCloud account.  I would like to set her up with her own account but I would like to share contacts and photos on the iCloud.  Is there a way to share this across 2 iCloud accounts?
    Thanks,

    It is possible to remove passwords from their accounts; so that they are not needed to log in.
    A passwordless admin account is a very bad idea. So if either of them are using admin accounts now (which they shouldn't be anyway), have them create a third account, make it admin, and then remove admin privileges and passwords from their own two user accounts. Keep a password on the admin account.

  • I have the newest Macbook pro with retina display, I recently installed Photoshop elements 11 and have noticed that elements 11 is very pixelated. Is there a way to fix this, or is elements 11 just not compatible with the new retina?

    Is there a way to fix photoshop elements 11 from being pixelated on my new Macbook Pro Retina Display?

    You may want to reference http://forums.adobe.com
    The problem is mentioned here: http://forums.adobe.com/message/5647016#5647016#5647016

  • Is there any way to undelete an App that was deleted by accident, while at the same time keeping all the info that was in the App?

    Is there any way to undelete an App that was deleted by accident, without loosing all the information that was in the App?
    Any help would be greatly appreciated.
    Thanx P.

    Only if you have an iPhone backup from the time before you deleted the app. App data and settings are part of the backup, but iTunes replaces the existing backup with a new one when you sync. Only backups used to restore the phone will not be replaced and marked with a time stamp.
    If you included the iphone backup folder into your computer backup routine, you could restore the folder and use the iphone backup to restore your phone. But all data will be set back to theat point in time when the backup was taken.
    More info here: iPhone and iPod touch: About backups

  • Is there any way to type your email address so that it would print with the push of one button, like a macro??

    Is there any way to type your email address (or any other information) so that it would print with the push of one key -- like a macro?

    Take a look at Text Expander:
    http://www.smilesoftware.com/TextExpander/

  • Is there any way for 2 bluetooth headsets to participate in a FaceTime call on the same device?

    From what I can tell, one cannot use two Bluetooth headsets at the same time, using the built-in reciever. However, it seems as though one can transmit audio to 2 devices using the KOKKIA i10, but the deal breaker is: can one send audio using 2 headets? Is there some obscure version of the Kokkia that will reciever audio as well?

    It sounds like you are using two independent libraries with a common media folder, whereas the plan would have been to ensure that both profiles were using the same library library database. Although you can place this within the Public folder I would normally create a shared library at the root of a drive, e.g. at X:\iTunes where X: is the drive that you want to use. See Make a split library portable for information on moving the library around back into a standard shape.
    As for duplicates, Apple's official advice on duplicates is here... HT2905: How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls such as lost ratings and playlist membership.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See thisthread for background, this post for detailed instructions, and please take note of the warning
    to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed.)
    The most recent version of the script can tidy dead links as long as there is at least one live duplicate to merge stats and playlist membership to and should cope sensibly when the same file has been added via multiple paths.
    tt2

  • Is there a way to add GPS location after importing to Photos?

    I would like to add GPS location data to photos I take with my DLSR.  In the past I was able to copy location data from a photo taken on my iPhone I take and copy it to all my DLSR photos.
    Can this be done in Photos?

    I actually bought Greenfinder and vCaddy (Golf GPS apps both in app store) and did extensive testing yesterday. You can see my full review here.
    http://forums.macrumors.com/showpost.php?p=6056655&postcount=20
    Bottom line - Could be a great alternative to a SkyCaddy or similar device
    Message was edited by: dhy8386

  • Is there any way to add a task/reminder from iCal or Mail besides adding flags that have no date reminders?

    Am I missing something? Is there a 3rd party software that does this? I came from Outlook with the ability to add tasks to my daily to-dos and give them start/end dates.  Where can I do this with OSX 10.7?

    Thanks for the feedback Kip - I did see this option in iCal, which BTW is not optimal at all as you have to retype the action item and due date. I was looking for a way to add to dos and reminders with due dates directly from Mail as I did with Outlook. I get a ton of emails that I want to follow-up on, but want to chhose when I get reminded, and actually have a remider pop-up when it is due/overdue.  Hope that makes sense.

  • Is there any way to add a credit card number from the iPhone for the app store

    Is there any way to add a credit card to my account from my phone my computer has crashed and I can't update any of my apps

    I don't believe so. I will have a closer look though and report back

  • HT201364 Without having to dig up some receipt is there a way to find out what year my iMac is from?

    Without having to dig up some receipt is there a way to find out what year my iMac is from?

    Check the model ID in the System Information
    Download and use  MacTracker to determine the year (and every other thing about the machine you could ever want to know).
    OT

Maybe you are looking for