Script task to read the column names dynamically and create a table in database based on excel column structure

Hello,
Can anyone help me out to write a vb.net script.
I need to read the column names from excel and based on that column names I need to create a table in database(I have more than one sheet in excel).
For each sheet columns will be changing and should create a table dynamically for each sheet.
Any help would be appreciated.

Refer the below script to read columns in each sheet.
Dim excelfile As String = Dts.Variables("ExcelPath").Value.ToString
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelfile + ";Extended Properties=Excel 8.0"
Dim oledbcon As New OleDb.OleDbConnection(connectionstring)
oledbcon.Open()
Dim dt As DataTable
Dim schemaTable As DataTable
Dim OLEDBCMD As New OleDb.OleDbCommand
Dim oledbdatareader As OleDb.OleDbDataReader
Dim columns As String = ""
dt = oledbcon.GetSchema("Tables")
Dim TABCOMMAND(20) As String
Dim TABCOUNT As Integer = 0
For Each row As DataRow In dt.Rows
TABCOMMAND(TABCOUNT) = "SELECT * FROM [" & row.Item("TABLE_NAME").ToString & "]"
OLEDBCMD.CommandText = TABCOMMAND(TABCOUNT)
OLEDBCMD.Connection = oledbcon
oledbdatareader = OLEDBCMD.ExecuteReader(CommandBehavior.KeyInfo)
schemaTable = oledbdatareader.GetSchemaTable()
For Each myfield As DataRow In schemaTable.Rows
For Each myproperty As DataColumn In schemaTable.Columns
If myproperty.ColumnName = "ColumnName" Then
columns = columns & myfield(myproperty).ToString & ","
MsgBox(myfield(myproperty).ToString)
End If
Next
Next
oledbdatareader.Close()
OLEDBCMD.Dispose()
Next
oledbcon.Close()
Regards, RSingh

Similar Messages

  • XI to read the action xml file and create a SAP notification in PM

    Hi All
    I am new to XI world can you please help me in doing this scenario.
    I have to read an XML file and create a Notification in PM module of SAP.
    Step by Step help would be great.
    Thanks in Advance
    Sai

    Hi Sai,
    To send data from XML file to SAP (any module) there are 2 ways..
    1. File to IDoc  and
    2. File to RFC...
      first Identify the concerned BAPI or IDOC for CREATION OF
    NOTIFICATION ...then do the  scenarios..
       for Step by stp process go through this link...
    New to XI
    regards,
    Ansar.

  • Script task error during the creation of partition by reading a table and using AMO - SSAS 2012

    Hi,
    I need to create SSAS (tabular) and process partitions in an authomatic manner. Moreover, the partitioning is respect to a category, an year and a month.
    Category, year and month are resident on a table to read to create the SSAS partitions.
    So, in a SSIS pkg:
    a. I've created a data flow task to read the SQL Server table having category, year and month data,
    b. I've connected the output of the ole db source as the input for a recordset destination, associated to an object variable,
    c. I've used a for each loop container (ado enumerator) specifying the object variable and three variables, for category, year and month,
    d. inside the for each loop container I've created a script task using AMO (visual basic) to control for any existing partitions, if not presents to create the new ones and then to process them.
    For the first iteration, a new partition has been created and processed successfully, but then, for other category, year and month values the script task fails. I've controlled the code many times and I've tried to put returning messageboxes but I've found
    anything. The error is a generic one and no other info are returned.
    Well, any suggests to me in order to solve this issue, please?
    Many thanks

    Hi, thanks, I've solved adding to the code end the SSAS server connection termination.
    Bye

  • Getting the column names dynamically

    hi gurus,
    i have list item populated with many table names from a schema.
    i have grid in oracle forms 10g and i want to fill the grid with the data that should come at least four/more columns.
    i want to fire the list change trigger when each time any one table name is selected/changed.
    how can i get the column names dynamically
    please give me the step by step process
    for filling the grid..

    hi ,
    by getting column names dynamically i am creating a record group
    using this below query
    SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <table_name>
    but when timestamp datatype is there then it is showing error cannot create group groupname
    but the record group is running successful on varchar2,number,date dayatypes
    if any alternative is there i mean to say without using record group then tell me or where is the problem

  • How to configure the schema name dynamically based on user input.

    configure the schema name dynamically based on user input.
    For ex:
    We have two schemas:
    Schema1  - base schema having 15 tables.
    Schema2 -  tables which is specific to modules. Having only 10 tables which is also available in Schema1
    Login to application using Schema 1
    Access a particlular module and select the country. Here country selection is identified.
    Based on the country selection, we need to connect the schema respectively.
    If the user selects France --> It should connect Schema1
    If the user selects Germeny --> It should connect schema2.
    Used: Eclipselink

    You may want to have a different persistence unit for each country, then you just need to switch persistence units, and can put the schema in your orm.xml file.
    You may also want to investigate EclipseLink multi-tenant support,
    http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/a_multitenant.htm
    You can the schema in a persistence unit in code using a SessionCustomizer and the tableQualifier.

  • Execute immediate with using clause to pass column name dynamically

    Hai,
    Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
    1. Column value as dynamic, which is working correctly.
    create or replace function testexeimm (acctnum char)
    return number as
    acctbal number;
    begin
    execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
    return acctbal;
    end;
    2. Column name as dynamic which is not working
    create or replace function testexeimm (colnam char)
    return char as
    acctbal char;
    begin
    execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
    return acctbal;
    end;
    Any help in this regard will be highly appericated.
    Regards
    Sridhar

    So the variable has to be numeric too:
    create or replace function testexeimm (colnam char)
    return number as
    acctbal number;
    begin
    execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
    return acctbal;
    end;Max
    http://oracleitalia.wordpress.com

  • Is there any way to read the field name,through the property binded to it.

    Hi
    I want to know that,is there any method exits with which i can find the field names of the screen,if i have the property attribute with me.
    as my req is to make the validation for the property attr,& check  how many fields are binded with the single property attr,i have read the property attr dynamically,now need to find the fields linked,& need to check how many fields have not field value,& through the error msg.

    just read the attribute binded to properties using code wizard ( Control + F7).
    Code generalted will be like :
    DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
        DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
        DATA ls_cn_check TYPE wd_this->element_cn_check.
        DATA lv_ca_check LIKE ls_cn_check-ca_check.
      navigate from <CONTEXT> to <CN_CHECK> via lead selection
        lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).
      get element via lead selection
        lo_el_cn_check = lo_nd_cn_check->get_element(  ).
      get single attribute
        lo_el_cn_check->get_attribute(
          EXPORTING
            name =  `CA_CHECK`
          IMPORTING
            value = lv_ca_check ).
    Here i have read attribute CA_CHECK.

  • Pass column names dynamically in report

    Hello experts,
    I am creating an ALV report where i need to pass the column names dynamically. if the current month is March and year is 2009. the column names should be as below
    March 2009 April 2009 May 2009 June 2009 ..............till Feb 2010 (total columns are 12)
    if the current month is June and year is 2010 it shoud be displayed as
    June 2010 July 2010 Aug 2010................till May2011
    I am actually calculating the forecast qty for each month and displaying in a report from the current month.
    How to write field catelog for this requirement?
    Thanks in Advance.
    Rajesh.

    I think in the fieldcat, at the time of declearation, you can alter the field description depending on the present month.
    If present_month = January
    wa_fieldcat-reptext_ddic = 'January'.       " Field description
    elseif present month = February.
    wa_fieldcat-reptext_ddic = 'February'.       " Field description
    on so on.....................
    Kuntal

  • Column names dynamically in Dynamic SQL

    Hi All,
    We can use Table Name dynamically in Dynamic SQL.
    Can we use column names dynamically?
    Thanks,
    Umasankar

    Hi Todd Barry,
    Thanks lot for your immediate response.
    Could you please tell me, how can we use column name dynamically?
    I tried but, I didnt get the correct result.
    Here is my coding.
    Declare
    SQL_String Varchar2(2000);
    Category varchar2(50):= 'ELECTRO_PLATING_413';
    Type ConstCurTyp is REF CURSOR;
    Const_Cv ConstCurTyp;
    vLab_name varchar2(80);
    Begin
    Execute Immediate 'Truncate table tto_lab_names';
    dbms_output.put_line(category);
    dbms_output.put_line(' ');
    SQL_String := 'Select lab_name from tto_constituents where :category is not null';
    Open Const_cv for SQL_String using category;
    Loop
    Fetch Const_Cv into vLab_Name;
    Exit When Const_Cv%NotFound;
    Insert into lab_names values(vLab_name);
    End Loop;
    Commit;
    Close Const_Cv;
    End;
    I am getting all the lab_names as result.
    Thanks,
    Umasankar
    null

  • HTML DB Chang column name dynamically

    Can I change the column name dynamically. for instance
    Today run my apply it will display the title of the columns this
    Column title: Wed Thu Fri
    04/22/05 04/23/05 04/24/05
    Data 45 34 34
    54 56 23
    Next week
    Column title: Wed Thu Fri
    05/03/05 05/04/05 05/05/05
    45 34 34
    54 56 23
    The date Change Dynamically?

    Go to your report and open report atributes. There you can choose the options for column names. Click on the pl/sql function and type this in:
    DECLARE v varchar2(20);
    begin
    v := to_char(SYSDATE, 'dd.mm.yy')||':'||to_char(SYSDATE+1, 'dd.mm.yy');
    RETURN v;
    END;
    This will set the first two columns to the specified dates. You can use this as one option.
    If the case is more complicated than you can do the following:
    1. create a number of items on your page - hidden
    2. compute the items with values once the page is loaded
    3. use item substitute string &ITEM. in the column name, which will use the item value as a name for the column.
    This way you are more flexible since you can use the item values for some columns only and have the other columns hardcoded.
    Denes Kubicek

  • How to read the whole name of a music title while scrolling down a list of titles? With the new iOs7 Music App there is no more black box showing the entire name!

    How to read the whole name of a music title while scrolling down a list of titles? The old software-app had the function to click for a longer time on a titles beginning letters until a black box revealed the entire name. I miss this function especially for my classical music, because lots of pieces start with similar words. E.g.:
    "Beethoven: Variations On "Ein Mädchen Oder Weibchen", Op. 66 - Var. 1"
    "Beethoven: Variations On "Ein Mädchen Oder Weibchen", Op. 66 - Var. 2"
    Scrolling in a list of title, I can't distinguish the titles, because just the first words are shown followed by: "...".
    That's horrible!

    Or you could include a width to your body style:
    body {
    background-image: url(Logo/sky1.jpg);
    background-position: center center;
    background-attachment: fixed;
    width: 75%;}
    It might work or not depending on your other color scheme.

  • Reading the document name.

    Hi all,
    I have a requirement where in a number of documents (.doc,pdf,xls,txt...etc) are placed in a fixed folder in C drive .
    i have to upload these documents to application server.
    The problem here is how to read the file names with file type through a normal report program.
    Help me plz .....
    thanks in advance.

    Use Class CL_GUI_FRONTEND_SERVICES
    Methods DIRECTORY_LIST_FILES  to get file attributes
    data: v_dir_path type string.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
      EXPORTING
        DIRECTORY                   = v_dir_path
       FILTER                      = '.'
       FILES_ONLY                  =
       DIRECTORIES_ONLY            =
      CHANGING
        FILE_TABLE                  = v_files
        COUNT                       = v_count
    EXCEPTIONS
       CNTL_ERROR                  = 1
       DIRECTORY_LIST_FILES_FAILED = 2
       WRONG_PARAMETER             = 3
       ERROR_NO_GUI                = 4
       NOT_SUPPORTED_BY_GUI        = 5
       others                      = 6
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Reading the printer name from the registry

    Hi,
    I am trying to use the following program to get the Printer name from my Registry.. this program has been taken from Forums.
    package yourpackage;
    import java.awt.Graphics;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import oracle.forms.ui.VBean;
    import oracle.forms.properties.ID;
    public class printDialog extends VBean
    private static final ID PRINTER = ID.registerProperty("PRINTER");
    public printDialog()
    class PrintObject implements Printable
    public int print (Graphics g, PageFormat f, int pageIndex)
    return NO_SUCH_PAGE;
    public Object getProperty(ID id)
    if (id == PRINTER) {
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new PrintObject());
    if (job.printDialog())
    return job.getPrintService().getName();
    } else {
    return null;
    } else {
    return null;}
    This program when compiled gives me the error as
    Error(32,12): method getPrintService() not found in class java.awt.print.PrinterJob
    I did set the project settings from Project-Project Settings and included Oracle Forms Libraries. But I still continue to get the error.
    I understood from the web that I need to put PrintService class which downloaded from the web as part of jnlp.jar
    How should I set this if this is the correct one?
    Early response would be highly appreciated
    Thanks a lot for your time and help
    Narain.

    Narain,
    I could swear I answered this on teh Jdeveloper forum ;-)
    The prin service is part pf Java 1.4, which means that it is not available in JInitiator today. Use the Java Plugin 1.4 and the required classes are present. JNLP stands for Java Network Launching Protocoll and has nothing to do with what you want to achieve.
    In addition, to read the printer names from Forms your jar file has to be signed.
    Frank

  • Read the page name

    Hi all,
    I am new 2 JSP
    I need to how to read the page name on the URL
    i.e http://localhost:8080/default.jsp
    and advice me on wich book to buy for writing JSP pages that access Microsift SQL Server Database.
    Regards

    What do you mean by read the page name? If you use request.getPathTranslated() it will return the path as seen by the browser. Is that what you're asking for?

  • Script to get all the Server Names on Central Site in the SCCM 2007 Hierarchy

    I want a script which will run on Central Site, and give all the SCCM server names in the hierarchy.
    Thanks and Regards, Mohd Zaid www.techforcast.com

    Duplicated post of
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/97910cd5-8f8b-46a7-86fa-c00932571d0d/script-to-get-all-the-server-names-on-central-site-in-the-sccm-2007-heirarchy?forum=configmgrgeneral
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

Maybe you are looking for