Datatable column add

Hi All ,, I am writing the following
$Datatable.Columns.Add("Servername")
$row=$datatable.Rows
$row.count
$row[1].Servername=$SQLServer
for($loopid=0;$loopid -le $row.count-1;$loopid++)
   $row[$loopid].servername=$Sqlserver
$Data.table.columns.add  will the new column to the last column of the whole table, are there anyway I can add a new column at the beginning ?

Hi sakurai_db,
you can do that by using the functionality of SetOrdinal, like this:
$Datatable.Columns.Add("ServerName").SetOrdinal(0)
(0) is the first position, if you want the second u use (1), etc.

Similar Messages

  • How to Format DataTable Column after load Datatable without extra loop ??

    How to Format Column after load Datatable without extra loop ??
    I dont want to do extra logic which can cause performance thing.
    I have datatable which get fill from Dataset after database query, now i need to format column as decimal but without extra logic.
    I was thinking to create clone and than Import row loop but it ll kill performance, its WPF application.
    Thanks
    Jumpingboy

    You cannot do any custom things at all without doing some "extra logic". Formatting a number as decimal is certainly not a performance killer in any way whatsoever though.
    If you are displaying the contents of the DataTable in a DataGrid you could specify a StringFormat in the XAML:
    <DataGrid x:Name="dg1" AutoGenerateColumns="False">
    <DataGrid.Columns>
    <DataGridTextColumn Header="Number" Binding="{Binding num, StringFormat=N2}"/>
    </DataGrid.Columns>
    </DataGrid>
    Or if you are using auto-generated columns you could handle the AutoGeneratingColumn event:
    public MainWindow() {
    InitializeComponent();
    DataTable table1 = new DataTable();
    table1.Columns.Add(new DataColumn("num")
    DataType = typeof(decimal)
    table1.Rows.Add(1.444444444444);
    table1.Rows.Add(7.444444444444);
    dg1.ItemsSource = table1.DefaultView;
    dg1.AutoGeneratingColumn += dg1_AutoGeneratingColumn;
    void dg1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) {
    if (e.PropertyName == "num") {
    DataGridTextColumn column = e.Column as DataGridTextColumn;
    column.Binding.StringFormat = "N2";
    <DataGrid x:Name="dg1" />
     Please remember to mark helpful posts as answer and/or helpful.

  • DataTable column Type

    Hi,
    I have a problem with a datatable object. The column "Qty" must have the precision that I had configured en General settigns, decimal placed, in the column "quantities", in this case 2. Its seams that I add a column to the datatable with Float type, internally takes Amounts precision, in this case 0. So I cant manage the 2 decimal in this datatable column.
    Code:
    Dim oDT As SAPbouiCOM.DataTable
    oDT.Columns.Add("Qty", SAPbobsCOM.BoFieldTypes.db_Float)
    Any Solution for this issue???
    Thanks in advance.
    Lucas

    My name is Guillermo, I'm currently working with Lucas on the same project and the problem is that based on customer requirements, "quantites" must display 2 decimal places and, "prices" and "ammounts" 0 decimal places. Having set up these values in SAP BO (through General Settings form), we use the next code to create a datatable with a column to store "quantities":
    Dim oDT As SAPbouiCOM.DataTable
    oDT.Columns.Add("Quantity", SAPbobsCOM.BoFieldTypes.db_Float)
    When using the type SAPbobsCOM.BoFieldTypes.db_Float, the values stored by the newly created column, display 0 decimal places taking, as I can only asume, the decimal places set for "ammounts" (0) not the ones set for "quantities" (2).
    We have tried the code as Daniel indicated in the response above (changing SAPbobsCOM.BoFieldTypes to SAPbouiCOM.BoFieldsType), and got the same results, data is still displayed with 0 decimals.
    Any other ideas?
    Thanks ins advance for your help.

  • Issue with passing expression to a hashmap key in a dataTable column

    hi all,
    Can someone help me with passing an expression like "123-456" to a hashmap key in my dataTable . In my dataTable i have t:columns tag which generates checkboxes for each row in the dynamic column .The value of checkbox must be identified by a combination of userID and accountID. So i want to set value of checkbox something like this'userID-account.ID' . But it never returns the right value since userID is taken as string instead i want the value of userID to be passed in that expression. Someone please help...iam struck with this issue from so long.Here is the code.
    page1.jsp:
    <t:dataTable id="groupuserlist"
                  var="user"            
                             value="#{manageuserscontroller.userList}"     // this is a list of userIDs
                 cellspacing="0"
                 preserveDataModel="false"
                 headerClass="topRow"
                 preserveSort="true"
                 summary="This table displays list of users for an accessgroup">
         <t:column>
          <f:facet name="header"><h:outputText value="User ID" /></f:facet>
          <t:outputText value="#{user.ID}" />
         </t:column>
         <t:column>
          <f:facet name="header"><t:commandSortHeader columnName="title" arrow="true"> <h:outputText value="Title"/> </t:commandSortHeader> </f:facet>
          <t:outputText value="#{user.title}" />
         </t:column>
          <t:columns var="cols" value="#{manageuserscontroller.selectedAGList}"> //selectedAGList is a list of accountIDs
          <f:facet name="header"><h:outputText value="#{cols.name}" /></f:facet>
          <h:selectBooleanCheckbox id="checkbox4" value="#{manageuserscontroller.selectedUserIds['user.ID-cols.ID]}" />
          </t:columns>
    </t:dataTable>Backing bean: In this selectedUserIds iam intentionally setting up key something like "userID-accountID" so that i can split the userID and accountID for later user
    private Map<String, Boolean> selectedUserIds = new HashMap<String, Boolean>();
             somebody please to my email. If you need further information iam very happy to provide any time. Also let me know if there is another way to get this job done..
    Thanks very much in advance

    Hi BalusC,
    I am very much thankful to you. I got my issue resolved only when i select one dynamic column. It doesn't seem to be working if i select multiple columns. Not sure where exactly my logic is going wrong. Here is a snippet of my code.. Please let me know if you find any mistake in it..Once again thanks very much..for your great help.
    jsp:
    <t:dataTable id="grouplist"
                  var="user"            
                   value="#{manageuserscontroller.userList}"     
                   styleClass="companyAdminMainTable ltgreen_Hrule marVertSml"
                 cellspacing="0"
                 preserveDataModel="false"
                 headerClass="topRow"
                 preserveSort="true"
                 summary="This table displays list of users for an account">
         <t:column>
          <f:facet name="header"><h:outputText value="User ID" /></f:facet>
          <t:outputText value="#{user.ID}" />
         </t:column>
         <t:column>
          <f:facet name="header"><t:commandSortHeader columnName="title" arrow="true"> <h:outputText value="Title"/> </t:commandSortHeader> </f:facet>
          <t:outputText value="#{user.title}" />
         </t:column>
          <t:columns id="dynamic" var="cols" value="#{manageuserscontroller.selectedAGList}">
          <f:facet name="header"><h:outputText value="#{cols.name}" /></f:facet>
          <h:selectBooleanCheckbox id="checkbox4" value="#{manageuserscontroller.selectedAGUserIds[user.ID][cols.accessGroupID]}" />
          </t:column>
          </t:columns>
    </t:dataTable>Backing bean:
    private Map<Integer, Map<Integer,Boolean>> selectedAGUserIds = new HashMap<Integer, Map<Integer,Boolean>>();
        private Map<Integer, Boolean> selectedAGIds = new HashMap<Integer, Boolean>();
    for(int j=0; j< selectedAGList.size(); j++){   //List of selected dynamic account columns
             for(int i=0; i < userList.size();i++){              // lisf of users
                   try {
                        int m = userList.get(i).getID();
                        int n = selectedAGList.get(j).getAccessGroupID();
                        selectedAGIds=(AccessGroupDAO.getUserMap1(userList.get(i).getID(),selectedAGList.get(j).getAccountID()));
                        selectedAGUserIds.put(userList.get(i).getID(),selectedAGIds);
                       System.out.println("hashmap value"+ selectedAGUserIds.get(m).get(n));
                        } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                 System.out.println("outer hashmap size"+ selectedAGUserIds.size());
          }DAO:
    public static Map<Integer,Boolean> getUserMap1(Integer userID, int accountID) throws Exception {
         Map<Integer, Map<Integer,Boolean>> selectedUserAGIds = new HashMap<Integer, Map<Integer,Boolean>>();
                    Map<Integer, Boolean> selectedAGIds = new HashMap<Integer, Boolean>();
          String sql="  select iusermetaid,iaccountid from useraccountlist where iusermetaid = userID and iaccountid = accountID ";
             ResultSet rs = executeSQL(sql);
             if(rs!=null & rs.next()){
                  System.out.println("record found");
                  Integer aid = rs.getInt("iaccountid");
                        selectedAGIds.put(aid, true);
             else{
                  System.out.println("record not found");
                  selectedAGIds.put(accessGroupID, false);
                  System.out.println("get the key value"+ selectedUserAGIds.get(userID).get(accessGroupID));
            System.out.println("Exiting accessgroupDAO");
             return selectedAGIds;
    }

  • Hiding exceeded data in h:dataTable columns

    hi,
    my requirement is I have to display some data in dataTable and I need to put fixed height for the columns.if the data in that column exceeds then the data should hide and onmouseover one tooltip should come showing the exceeded data.
    but the jsf data table is not hiding the data at all.I have given width and height for that column using css but it is showing the data completely.
    please tell me how can I do this one.

    Hi,
    I tried using overflow property also..but i is not working for me..I am sending my code also
    <h:dataTable id="popresults"
    value="#{popsearch.popList}"
    var="pop"
    columnClasses="name"
    border="0" rowClasses="standardTable_Row2,standardTable_Row1"
    headerClass="DHTMLSuite_tableWigdet_headerCellDown_searchlist" style="vertical-align:middle;" styleClass="tableList_search" width="100%" cellpadding="1" cellspacing="0">
              <h:column>
    <f:facet name="header">
    <h:outputText value="POP Id" style="text-decoration:none;color:black;font-weight:bold;"/>
         </f:facet>
              <h:commandLink id="id"
                             action="#{popdetails.getPOPDetails}"
                             actionListener="#{popsearch.selectPOP}" onmouseover="ddrivetip('#{pop.id}')" onmouseout="hideddrivetip()">
                   <h:outputText value="#{pop.id}" style="text-decoration: none;color: black;border-bottom: 1px solid black;" />
                   <f:param id="popId"
                             name="popId"
                             value="#{pop.id}" />
                   <f:param id="discriminator"
                             name="discriminator"
                             value="#{pop.discriminator}" />
              </h:commandLink>
         </h:column>
         <h:column>
    <f:facet name="header">
         <h:panelGrid columns="2">
         <h:commandLink value="Provider Id" action="#{popsearch.getPopResults}" actionListener="#{popsearch.sortPidDataList}" style="text-decoration:none;color:black;font-weight:bold;">
    <f:attribute name="providerid" value="providerID"/>
         </h:commandLink>
         <h:graphicImage id="pidarrowup" url="#{popsearch.popimg}" rendered="#{popsearch.pidren}"/>
    </h:panelGrid>
    </f:facet>
    <h:outputLabel value="#{pop.providerID}" onmouseover="ddrivetip('#{pop.providerID}')" onmouseout="hideddrivetip()"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Modem Phone"/>
    </f:facet>
    <h:outputLabel value="#{pop.modemPhone}" onmouseover="ddrivetip('#{pop.modemPhone}')" onmouseout="hideddrivetip()"/>
    </h:column>
         <h:column>
    <f:facet name="header">
    <h:panelGrid columns="2">
         <h:commandLink value="POP Class" action="#{popsearch.getPopResults}" actionListener="#{popsearch.sortPclassDataList}" style="text-decoration:none;color:black;font-weight:bold;">
    <f:attribute name="popClass" value="discriminator"/>
         </h:commandLink>
                        <h:graphicImage id="pclassarrowup" url="#{popsearch.popimg}" rendered="#{popsearch.pclassren}"/>
    </h:panelGrid>
    </f:facet>
    <h:outputText value="Broadband" rendered="#{pop.discriminator eq 'B'}">
    </h:outputText>
    <h:outputText value="Dial" rendered="#{pop.discriminator eq 'D'}">
    </h:outputText>
    </h:column>
         <h:column>
    <f:facet name="header">
    <h:outputText value="Location" />
    </f:facet>
    <h:outputLabel value="#{pop.siteAddress}" rendered="#{pop.discriminator eq 'B'}" onmouseover="ddrivetip('#{pop.siteAddress}')" onmouseout="hideddrivetip()"/>
    </h:column>
    </h:dataTable>
    and css is
    .name {
    width: 25px;
    text-align: left;
    nowrap:true
    white-space:nowrap
    overflow:hidden
    please tell me If I missed any thing.

  • Datatable column rows

    Hi,
    In my application I need to display a list of images from a database table. Now if I do as:
    <h:datatable value="#{myBean.x}" var="item">
    <h:column>
    <h:graphicimage url="{#item.pic}"/>
    </h:column>
    I end with a narrow one column table like.
    x
    x
    x
    x
    x
    while I want to get
    x x x x
    x x x x
    x x x x
    How can I achieve this?
    thanks

    You can use myfaces implementation of dataList
    <t:dataList var="imgList" value="#{list.imageList}" layout="simple" dir="ltr">
        <h:graphicImage url="#{imgList.getImagePath}" />     
    </t:dataList>dataList is similar to the dataTable only diffrence is you can render the table value in single row

  • Dynamic Columns Add

    Hi,
    I have a One Small requirements. Please suggest which method is best.
    If user add the columns into DB that will be automatically add the columns into the Report.
    Ex: In my Table A initially have Col1,Col2 then it should be display into report
    Table A
    Col1,Col2
    After few days user added Col3 into Table A that should be added automatically.
    Thank you
    Regards
    Venkat

    Hi Venkat,
    According to your description that you want to dynamically add the new columns in the table when you add new columns in the DB table, right?
    Generally, the matrix's column group can dynamic increase in the report, if the data of the new columns are all numeric type, you can use the unpivot function to turn the column name of these fields to a single row and then you can add it in the column group
    or there is no better method to do the dynamic add to tablix, I would suggest you to add new column manually as you don't have too many columns to add at a time.
    Similar threads with details steps for your reference:
    https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings
    If your still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Missing Datatable Column Data

    I'm missing data in the enabled and lastsuccess column. The data exist, but for some reason the table does not even render the rows for that column, its one big blank square.
         <h:dataTable border="1" value="#{UserMgr.allUsers}" var="user0" style="width: 80%">
                                       <h:column id="username"> <f:facet name="header"> <h:outputText
                                       value="User Name"></h:outputText> </f:facet> <h:outputText value="#{user0.username}"></h:outputText></h:column>
                                       <h:column id="firstname"> <f:facet name="header"> <h:outputText
                                            value="First Name"></h:outputText> </f:facet> <h:outputText value="#{user0.firstname}"></h:outputText></h:column>
                                       <h:column id="lastname"> <f:facet name="header"> <h:outputText
                                            value="Last Name"></h:outputText> </f:facet> <h:outputText value="#{user0.lastname}"></h:outputText></h:column>
                                       <h:column id="email"> <f:facet name="header"> <h:outputText
                                            value="E-mail Address"></h:outputText> </f:facet> <h:outputText value="#{user0.email}"></h:outputText></h:column>
                                       <h:column id="lastlogin"> <f:facet name="header"> <h:outputText
                                            value="Last Login"></h:outputText> </f:facet> <h:outputText value="#{user0.lastsuccess}"></h:outputText></h:column>
                                       <h:column id="failures"> <f:facet name="header"> <h:outputText
                                            value="Failures"></h:outputText> </f:facet> <h:outputText value="#{user0.numfails}"></h:outputText></h:column>
                                       <h:column id="enabled"> <f:facet name="header"> <h:outputText
                                            value="Enabled"></h:outputText> </f:facet> <h:outputText value="#{$user0.disabled}"></h:outputText></h:column>
                                  </h:dataTable>

    Ignore, I'm an idiot

  • New column add in supplemental log group

    Hi All,
    How to add the new column in existing supplemental log group.
    Ex.
    SQL> desc scott.emp
    Name Null? Type
    EMPNO NOT NULL NUMBER(4)
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    And the existing supplemental group is
    Alter table emp add supplemental log group emp_log_grp (empno,ename,sal) always;
    Now I want to add comm column in log group.
    Pls. help.
    Thanks
    Naresh

    did you try..
    ALTER TABLE hr.departments ADD SUPPLEMENTAL LOG GROUP log_group_dep_pk
    (comm) ALWAYS;

  • How to sort multiple t:dataTable columns with Tomahawk?

    Hello, I'm using Tomahawk with MyFaces and I'm trying to sort my table by couple of columns. I have year and month cols and when I sort by year and two years are equal, I want to subsort by the months. I actually tried to create a sort method taking sortColumn and ascending as params, but it didn't get invoked by the app. I also tried to put commandButton as headers which call sort(ActionEvent), but it still didn't get invoked. May anyone show me how could I write a backend for the sorting?
    Thanks in advance!
    Regards,
    Mario

    Yes, there is a comparator. I don't find the problem so much TOmahawk specific, I'm actually trying to solve it without it too. But I found where the problem is - in the <t:column> tag - when sortable attribute is enabled, it doesn't call any external methods, no matter if they are actions or actionListeners.
    So when I removed the sortable attribute, my backend method got called. :)
    Regards,
    Mario

  • BPS-Configuration of data columns-Add variable to Fiscal year/period

    Dear experts,
    I have the following message when I run the manual input excel layout -
    >>
    "The environment has changed; the layout can no longer be executed"
    I guess actually it is because of the variable i added to a charcter "0FISCPER" in the data colomn.
    When i remove the variable and replace it with a fixed value, the error message disappeared and the excel layout works very well.
    Could anybody tell me what is the root cause for this error? How could I debug it and correct it?
    Thanks very much in advance!!!

    Thanks for you both for the reply.
    Hi, Sharma,
    The layout works when I restrict the 0FISCPER with a fixed value directly on the layout definition level.  The variable I made was defined at the planning area level and added to the 0FISCPER at the layout level in the u201Cdata colomnu201D.
    Hi, Panda,
    The fisper variable is devrived from a u201CFixed valueu201D which I defined at the planning area level.

  • Object browser displays only First 31 columns in Data section of a table.

    I need to download data from a table which has almost 60 columns. When i selected table from object browser and clicked on data section of this table, only first 31 columns are displayed and when clicked on download, only the data for those 31 columns is displayed. How to download data of all colums of this table

    Hello Jim
    I have the same problem, but my limit is 21 columns. I think the limit is caused by the DataReader SchemaTable. Check the following value:
    IDataReader.GetSchemaTable().Columns.Count
    Columns in the SchemaTable are Metadata (ColumnName, ColumnSize, DataType, AllowDBNull...), the columns that are selected with the DataReader are stored in the SchemaTable Rows Property.
    For Oracle and SQLServer i used this workaround:
    DataTable dataTable = IDataReader.GetSchemaTable();
    while (dataTable.Columns.Count < dataTable.Rows.Count)
        dataTable.Columns.Add("Dummy" + dataTable.Columns.Count.ToString(), typeof(bool));
    I think developpers of CR use the Columns.Count instead of Rows.Count property when getting the data out of the DataReader.
    Regards,
    Walter

  • SQL bulk copy from csv file - Encoding

    Hi Experts
    This is the first time I am creating a PowerShell script and it is almost working. I just have some problems with the actual bulk import to SQL encoding from the text file since it replaces
    special characters with a question mark. I have set the encoding when creating the csv file but that does not seem to reflect on the actual bulk import. I have tried difference scenarios with the encoding part but I cannot find the proper solution for that.
    To shortly outline what the script does:
    Connect to Active Directory fetching all user - but excluding users in specific OU's
    Export all users to a csv in unicode encoding
    Strip double quote text identifiers (if there is another way of handling that it will be much appreciated)
    Clear all records temporary SQL table
    Import records from csv file to temporary SQL table (this is where the encoding is wrong)
    Update existing records in another table based on the records in the temporary table and insert new record if not found.
    The script looks as the following (any suggestions for optimizing the script are very welcome):
    # CSV file variables
    $path = Split-Path -parent "C:\Temp\ExportADUsers\*.*"
    $filename = "AD_Users.csv"
    $csvfile = $path + "\" + $filename
    $csvdelimiter = ";"
    $firstRowColumns = $true
    # Active Directory variables
    $searchbase = "OU=Users,DC=fabrikam,DC=com"
    $ADServer = 'DC01'
    # Database variables
    $sqlserver = "DB02"
    $database = "My Database"
    $table = "tblADimport"
    $tableEmployee = "tblEmployees"
    # Initialize
    Write-Host "Script started..."
    $elapsed = [System.Diagnostics.Stopwatch]::StartNew()
    # GET DATA FROM ACTIVE DIRECTORY
    # Import the ActiveDirectory Module
    Import-Module ActiveDirectory
    # Get all AD users not in specified OU's
    Write-Host "Retrieving users from Active Directory..."
    $AllADUsers = Get-ADUser -server $ADServer `
    -searchbase $searchbase -Filter * -Properties * |
    ?{$_.DistinguishedName -notmatch 'OU=MeetingRooms,OU=Users,DC=fabrikam,DC=com' `
    -and $_.DistinguishedName -notmatch 'OU=FunctionalMailbox,OU=Users,DC=fabrikam,DC=com'}
    Write-Host "Users retrieved in $($elapsed.Elapsed.ToString())."
    # Define labels and get specific user fields
    Write-Host "Generating CSV file..."
    $AllADUsers |
    Select-Object @{Label = "UNID";Expression = {$_.objectGuid}},
    @{Label = "FirstName";Expression = {$_.GivenName}},
    @{Label = "LastName";Expression = {$_.sn}},
    @{Label = "EmployeeNo";Expression = {$_.EmployeeID}} |
    # Export CSV file and remove text qualifiers
    Export-Csv -NoTypeInformation $csvfile -Encoding Unicode -Delimiter $csvdelimiter
    Write-Host "Removing text qualifiers..."
    (Get-Content $csvfile) | foreach {$_ -replace '"'} | Set-Content $csvfile
    Write-Host "CSV file created in $($elapsed.Elapsed.ToString())."
    # DATABASE IMPORT
    [void][Reflection.Assembly]::LoadWithPartialName("System.Data")
    [void][Reflection.Assembly]::LoadWithPartialName("System.Data.SqlClient")
    $batchsize = 50000
    # Delete all records in AD import table
    Write-Host "Clearing records in AD import table..."
    Invoke-Sqlcmd -Query "DELETE FROM $table" -Database $database -ServerInstance $sqlserver
    # Build the sqlbulkcopy connection, and set the timeout to infinite
    $connectionstring = "Data Source=$sqlserver;Integrated Security=true;Initial Catalog=$database;"
    $bulkcopy = New-Object Data.SqlClient.SqlBulkCopy($connectionstring, [System.Data.SqlClient.SqlBulkCopyOptions]::TableLock)
    $bulkcopy.DestinationTableName = $table
    $bulkcopy.bulkcopyTimeout = 0
    $bulkcopy.batchsize = $batchsize
    # Create the datatable and autogenerate the columns
    $datatable = New-Object System.Data.DataTable
    # Open the text file from disk
    $reader = New-Object System.IO.StreamReader($csvfile)
    $columns = (Get-Content $csvfile -First 1).Split($csvdelimiter)
    if ($firstRowColumns -eq $true) { $null = $reader.readLine()}
    Write-Host "Importing to database..."
    foreach ($column in $columns) {
    $null = $datatable.Columns.Add()
    # Read in the data, line by line
    while (($line = $reader.ReadLine()) -ne $null) {
    $null = $datatable.Rows.Add($line.Split($csvdelimiter))
    $i++; if (($i % $batchsize) -eq 0) {
    $bulkcopy.WriteToServer($datatable)
    Write-Host "$i rows have been inserted in $($elapsed.Elapsed.ToString())."
    $datatable.Clear()
    # Add in all the remaining rows since the last clear
    if($datatable.Rows.Count -gt 0) {
    $bulkcopy.WriteToServer($datatable)
    $datatable.Clear()
    # Clean Up
    Write-Host "CSV file imported in $($elapsed.Elapsed.ToString())."
    $reader.Close(); $reader.Dispose()
    $bulkcopy.Close(); $bulkcopy.Dispose()
    $datatable.Dispose()
    # Sometimes the Garbage Collector takes too long to clear the huge datatable.
    [System.GC]::Collect()
    # Update tblEmployee with imported data
    Write-Host "Updating employee data..."
    $queryUpdateUsers = "UPDATE $($tableEmployee)
    SET $($tableEmployee).EmployeeNumber = $($table).EmployeeNo,
    $($tableEmployee).FirstName = $($table).FirstName,
    $($tableEmployee).LastName = $($table).LastName,
    FROM $($tableEmployee) INNER JOIN $($table) ON $($tableEmployee).UniqueNumber = $($table).UNID
    IF @@ROWCOUNT=0
    INSERT INTO $($tableEmployee) (EmployeeNumber, FirstName, LastName, UniqueNumber)
    SELECT EmployeeNo, FirstName, LastName, UNID
    FROM $($table)"
    try
    Invoke-Sqlcmd -ServerInstance $sqlserver -Database $database -Query $queryUpdateUsers
    Write-Host "Table $($tableEmployee) updated in $($elapsed.Elapsed.ToString())."
    catch
    Write-Host "An error occured when updating $($tableEmployee) $($elapsed.Elapsed.ToString())."
    Write-Host "Script completed in $($elapsed.Elapsed.ToString())."

    I can see that the Export-CSV exports into ANSI though the encoding has been set to UNICODE. Thanks for leading me in the right direction.
    No - it exports as Unicode if set to.
    Your export was wrong and is exporting nothing. Look closely at your code:
    THis line exports nothing in Unicode"
    Export-Csv -NoTypeInformation $csvfile -Encoding Unicode -Delimiter $csvdelimiter
    There is no input object.
    This line converts any file to ansi
    (Get-Content $csvfile) | foreach {$_ -replace '"'} | Set-Content $csvfile
    Set-Content defaults to ANSI so the output file is converted.
    Since you are just dumping into a table by manually building a recorset why not just go direct.  You do not need a CSV.  Just dump theresults of the query to a datatable.
    https://gallery.technet.microsoft.com/scriptcenter/4208a159-a52e-4b99-83d4-8048468d29dd
    This script dumps to a datatable object which can now be used directly in a bulkcopy.
    Here is an example of how easy this is using your script:
    $AllADUsers = Get-ADUser -server $ADServer -searchbase $searchbase -Filter * -Properties GivenName,SN,EmployeeID,objectGUID |
    Where{
    $_.DistinguishedName -notmatch 'OU=MeetingRooms,OU=Users,DC=fabrikam,DC=com'
    -and $_.DistinguishedName -notmatch 'OU=FunctionalMailbox,OU=Users,DC=fabrikam,DC=com'
    } |
    Select-Object @{N='UNID';E={$_.objectGuid}},
    @{N='FirstName';Expression = {$_.GivenName}},
    @{N='LastName';Expression = {$_.sn}},
    @{N=/EmployeeNo;Expression = {$_.EmployeeID}} |
    Out-DataTable
    $AllDUsers is now a datatable.  You can just upload it.
    ¯\_(ツ)_/¯

  • DataAdapter MissingSchemaAction.Ignore doesn't work

    Hello,
    I use the Official Oracle ODP.NET Managed Driver 12.1.21 nuget package and DataAdapter MissingSchemaAction.Ignore property doesn't work well.
    This is my code :
    var myTableName = "User";
    var oneColumnOfMyTable = "Id";
    var dataSet = new DataSet();
    var dataTable = dataSet.Tables.Add();
    dataTable.Columns.Add(oneColumnOfMyTable);
    var dataAdapter = new OracleDataAdapter("SELECT * FROM " + myTableName, new OracleConnection(myConnectionString));
    dataAdapter.MissingMappingAction = MissingMappingAction.Passthrough;
    dataAdapter.MissingSchemaAction = MissingSchemaAction.Ignore;
    dataAdapter.Fill(dataTable);
    I got this following exception :
    An unhandled exception of type 'System.ArgumentException' occurred in Oracle.ManagedDataAccess.dll
    Additional information: Column 'OtherColumnName' does not belong to table Table1.
    If I use the latest version of this other nuget package : Oracle Data Provider for .NET (ODP.NET) Managed Driver 121.1.2
    there is no exception.
    Cordially,
    Stephane.

    Please post questions related to MVC in the ASP.NET forums (http://forums.asp.net ).

  • Parsing XML with .ReadXml

    Hi,
    I have an xml file which I'm parsing with following code
    //check if the xml is properly parsed
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(strXML);
    //load the data set from the valid xml string
    System.IO.StringReader sr = new System.IO.StringReader(strXML);
    ds.ReadXml(sr);
    The xml has following tags:
    <trlFlags>
    <trlUpdDepCust />
    <trlCatCust />
    <trlFuelOnly />
    <trlFuelSale />
    </trlFlags>
    When I look the content of table trlFlags I see columns trlUpdDepCust, trlCatCust, trlFuelOnly, etc. All rows in the table have blank value in these columns.
    This is not that I want. I want that a row in trlFlags table had a value, say, 1 in trlUpdDepCust column if <trlUpdDepCust /> tag is present.
    Is it doable?
    Thanks.
    Remember to mark as an answer if this post has helped you.

    Magnus, thank you for your help.
    Let me clarify the issue using the example below.
    Node 1. 
            <trlFlags>
    <trlFstmp />
            </trlFlags>
    Node 2:
    <trlFlags>
    <trlPLU />
    </trlFlags>
    Here is the desired output:
    Remember to mark as an answer if this post has helped you.
    Hi lgor,
    From your xml file, this is not good xml format.
    Here give you a sample about dataset.ReadXml() from MSDN.
    <XmlDS>
    <table1>
    <col1>Value1</col1>
    </table1>
    <table1>
    <col1>Value2</col1>
    </table1>
    </XmlDS>
    DataSet dataSet = new DataSet();
    DataTable dataTable = new DataTable("table1");
    dataTable.Columns.Add("col1", typeof(string));
    dataSet.Tables.Add(dataTable);
    string xmlData = "<XmlDS><table1><col1>Value1</col1></table1><table1><col1>Value2</col1></table1></XmlDS>";
    System.IO.StringReader xmlSR = new System.IO.StringReader(xmlData);
    dataSet.ReadXml(xmlSR);
    Reslut
    The ReadXml method provides a way to read either data only, or both data and schema into a
    DataSet from an XML document.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • RDC : connect Dataset to a Report

    Post Author: Chaux
    CA Forum: Data Connectivity and SQL
    My report is using a Acces database (MDB file).
    i m have to modify my report by code, so i need RDC.
    i m building a dataset, (not connected to physical datbase)
    DataSet.Tables.Add(TableName)
    DataTable.Columns.Add(ColumnsName, type)
    DataRow Row = DataTable.NewRow()
    Row&#91;x&#93; = data
    I want to connect this dataset to my report ,
    using setdatasource it do nothing...
    When i m trying to modify the ConnectionProperties
    Crystal Report prompt a windows, and ask me the physical datasource ...
    So, how can i connect the dataset to my report ?

    Hello Chris,
    I have never seen any code with 2 datasets.
    Anyway, please see here some [VB samples for .NET|https://smpdl.sap-ag.de/~sapidp/012002523100006252812008E/net_web_smpl.exe].
    Maybe you can change this code to your needs.
    [Please see here for more samples|https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm]
    Best regards
    Falk

Maybe you are looking for

  • How are the Basis Config Steps involved in sending an SMS through Workflows

    Hi Every one, WE are implementing sending SMS's through workflows what are the various Configs that need to be maintained.. Regards, Raj

  • Cannot see cluster disk resources after updating Windows base MP

    Hello - we've recently updated the Windows base MP for SCOM 2007 R2.  Once we did that we lost monitoring of our clustered disk resources.  They're discovered but not monitored any more.  Can someone please help!!! TIA Mike Zamborini

  • Confusing list of items installing Production Premium CS5

    I'm installing Production Premium CS5 (upgrade from CS3 using serial number, onto a new machine). The list of items to be installed, "all" of which are checked (on) by default, includes the following two items: · Photoshop CS5 (64-bit) · Photoshop CS

  • Trouble with tables  - formatting

    Is there a way to set up a template for tables within a project - same size, borders, shading, that kind of thing? Can you do this in the .css? I am kind of new to using .css, and mine is pretty basic right now. thanks, Leisa

  • The JMX Monitoring APIs for OSB

    hi I know Using the JMX Monitoring APIs can monitor Oracle Service Bus at run time to know how many messages in a particular service have processed successfully and how many have failed. but those are Statistical Information . i want to monitor the d