[help] How do I know if the column exists in the table or not?

Hi all, someone can tell me how to write code in c# help me to see if the field exists.

If there isn't then I want to change the table to include this column also

I am able to write the code for alter table, but I don't know how to check for its existence/nonexistence m

My modification code

{color: #800000} cmd.CommandText = 'alter table' + row. ToString() + "Add (" + It'squality + "varchar2 (50)", + ")"
sTimeStamp + "varchar2 (50)," +
sValue + "varchar2 (50));
cmd.CommandType = CommandType.Text;
cmd. ExecuteReader();
{color}


Just iterate datatable after completion and are looking for your column.

        public static DataTable MaterializeTableStructure(string _connectionString, string _tableName)
        {
            DataSet ds = null;
            using (OracleConnection _oraconn = new OracleConnection(_connectionString))
            {
                try
                {
                    _oraconn.Open();
                    string sql = "SELECT COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM user_tab_columns where table_name='" + _tableName + "'";
                    using (OracleCommand cmd = new OracleCommand(sql, _oraconn))
                    {
                        cmd.CommandType = CommandType.Text;
                        using (OracleDataAdapter da = new OracleDataAdapter(cmd))
                        {
                            ds = new DataSet("MaterializeTableStructure");
                            da.Fill(ds);
                        }
                    }
                }
                catch (OracleException _oraEx)
                {
                    throw (_oraEx); // Actually rethrow
                }
                catch (System.Exception _sysEx)
                {
                    throw (_sysEx); // Actually rethrow
                }
                finally
                {
                    if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
                        _oraconn.Close();
                }
            }
            if (ds != null)
                return ds.Tables[0];
            else
                return null;
        }

r,
Dennis

Tags: Database

Similar Questions

  • How do to know all the tables on peoplesoft (on Oracle 8.1) with data

    I need to know all the tables on peoplesoft (on Oracle 8.1) < strong > with < facilities > data
    and ignore the tables without data.

    It takes to write a pl/sql procedure or is there an easy solution?
    I wrote an example of code, but I am disconnected programming
    for the long and I need help.
    Thanks in advance
    Pls answer
    _______________
    Cursosr curtab is select table_name from dba_tables;
    curtab() loop
    Select count (*) x from curtab;
    If x & gt; 0
    UTL_FILE. Write ('curtab')
    on the other
    null;
    endif;
    end loop;
    ____________________

    Julia wrote:
    I need to know all the tables on peoplesoft (on Oracle 8.1) with data
    > & ignore tables without data.
    >
    > It takes to write a pl/sql procedure or is there an easy solution?
    > I wrote a code example, but I am disconnected programming
    > for a long time and I need help.
    > Thanks in advance
    > Pls answer
    > _______________
    > Cursosr curtab is select table_name from dba_tables;
    > curtab() loop
    > select count (*) x from curtab;
    > If x > 0
    > utl_file.write ('curtab')
    > other
    > null;
    > endif;
    > end of loop;
    > ____________________

    Consider using the user_tables and it works the relevant schema rather than dba_tables breast or of all_tables as these allows you to specify the schema name too will require.

    set serveroutput on;
    
    DECLARE
      cursor curtab is
        select table_name
        from   user_tables;
      --from   all_tables where owner = '';
      v_cnt NUMBER;
    BEGIN
      FOR t IN curtab
      LOOP
        EXECUTE IMMEDIATE 'select count(*) from '||t.table_name INTO v_cnt;
        IF v_cnt > 0 THEN
          DBMS_OUTPUT.PUT_LINE(t.table_name);
        END IF;
      END LOOP;
    END;
    /
    

    Or...

    Ensure that statistics were collected for the schema and examine the value of num_rows in the user_tables view. ;)

  • In safari how do I know if the site I bookmark is an existing already or not?

    In safari how do I know if the site I bookmark is an existing already or not?

    I bookmarked many sites and it is very difficult to follow and to organize because safari does not indicate if the site is set bookmark or not.

    I think it's a very obvious feature.

    I really don't understand why safari does not offer this feature simple when all other browsers.

    If anyone knows an extension that will solve this problem please let me know.

    Don't know if someone is having a similar sense of frustration about this Apple let it please. Apple - Safari - Feedback

    PS I know that I can search in bookmarks menu, but I find it very very inefficient.

    Unfortunately, you can not in Safari. You can see the App Store for a bookmark duplicate finder app.

    Also, since you favorite many sites and it is difficult to keep track of, you might have better luck using the Firefox Web browser

    They have an add we can help.

    https://addons.Mozilla.org/en-us/Firefox/addon/bookmark-duplicate-cleaner/

    Certainly, you can send your comments to Apple!

  • How will I know that the Windows Xp pro product key is already registered or not before you buy

    In fact, I'm going to buy Windows XP Professional and I see the product key is spent outside of the RAP and it is visible to everyone so here is the possibility that someone already uses this key and register online. I just want to know that how I know that the key is not yet register online before you buy.

    Hello


    Where will you buy Windows XP computer?

    You can contact Microsoft customer service to improve the assistance.
    http://support.Microsoft.com/kb/295539

    Hope this information helps.
  • I can't tell if ad hoc does not work, how do I know if the files are shared?

    I have files shared between a computer with Windows7 and the other with Vista.  I followed the instructions of preparation for each computer for file sharing process.  I have set up a network of working groups and they both have successfully connected.  The problem is that I can't tell if they recognize the other computer and when I go the file to share, I can't have information about the files on the computer in the face.  Yes, computers have seen and write options in the file to share.  When I try to access some forms in the file I can't the information I'm looking for on the files on the computer in the face.  How will I know if the computers are connected to the file sharing?

    Hello

    Were there any changes made on the computer before the show?

    Method 1:

    I suggest you to refer to the links and check if it helps:

    File sharing essentials

    http://Windows.Microsoft.com/en-us/Windows-Vista/file-sharing-essentials

    Share files with anyone

    http://Windows.Microsoft.com/en-us/Windows-Vista/share-files-with-someone

    Method 2:

    I suggest you to refer to the article and see if it helps:

    Networking of computers running different versions of Windows

    http://Windows.Microsoft.com/en-us/Windows-Vista/Networking-home-computers-running-different-versions-of-Windows

    Method 3:

    I also suggest you to check the settings of firewall on the computer. I also suggest you to disable the third-party firewall installed on the computer and check if the problem persists.

    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software

    Note: run the computer without antivirus software or firewall is a potential threat to the computer; Be sure to activate security software after completing the troubleshooting steps and after identifying the problem.

  • How do you know if the software was preinstalled or not?

    I want to uninstall all the programs that I don't use or I do not require so that I can have enough space on my C:. So, how do you know if the software is required for my system or not? If anyone can help me with this, I'll be very grateful.

    Thank you

    Hello

    If you don't know what it is, do not uninstall it.

    ____________________________________________________

    To clear up the problems of lack of space on your hard disk, follow these steps:

    This free program allows you to see what is taking place.

    http://www.Jam-software.com/treesize_free/

    Also check how much space system restore uses:

    http://Windows.Microsoft.com/en-us/Windows7/how-much-disk-space-does-System-Restore-require

    _____________________________________

    You can clean your hard drive using these two methods.

    "Delete files using Disk Cleanup"

    http://Windows.Microsoft.com/en-us/Windows/delete-files-using-disk-cleanup#delete-files-using-disk-cleanup=Windows-7

    Using the free CCleaner program:

    http://www.Piriform.com/CCleaner

    In NO case use the registry cleaning Option in CCleaner

    _____________________________________

    Download, install, update and scan your system with the free version of Malwarebytes AntiMalware:

    http://www.Malwarebytes.org/products/malwarebytes_free

    And Norton Backup, if you are using Norton, can do strange things with filling of hard drive space.

    See you soon.

  • How do I know what the maximum number of agents I can put on a hyperic serv

    How do I know what the maximum number of agents I can put on a hyperic server. ?? IM using the built in database on a linux unbuntu 4 cpu system ' s2592 MHZ. 7GB of Ram. I assumed that the
    disk space can be the most important question? Any suggestions or any help to determine when to stop adding customers would be useful. We can use open source, but are also
    talk about the EE version. The Hyperic server type would make a difference in space etc.?

    Disk i/o is probably a bit more critical than the disk space that the DB generally is not larger than 10-15 concerts.

    Ability wise, your system is CPU/RAM.  Disk i/o will probably be your main bottleneck and the thing that will determine the maximum number of agents that can have on the server.

    Splitting of the DB from the HQ server would certainly help in the perspective of General load.  Definitely put the DB a system with several piles of discs (part of a San, fast raid) will help you in the disk i/o.

    If I was trying to answer the same question, I guess that I look at the Scriptures on disk on the DB as starting point, test the drive with systat/iostat or something to see what the drive is capable of in terms of read/write speeds and also look at postgres for slow queries, duration of execution of query, used memory and cpu.  Naturally, I would do the majority of "look at her" go to HQ itself :)

    Post edited by: ama

  • How do I know if the two tables are the same in the data they contain

    Hello

    How will I know if the two tables are the same in the data they contain?

    Hello

    Please check this thread [compare all columns | http://forums.oracle.com/forums/thread.jspa?messageID=3166309�].

    Kind regards

  • How will I know when the synchronization is complete?

    Hello
    Is someone can you please tell me how do I know when the synchronization is complete?

    I paired a device (smart phone Samsung) - it worked good 10 minutes, yet on my phone says sync is complete, but any of the bookmarks do not appear on my computer 'main '.

    Hello.

    It is possible to "Synchronize now" in the version of office when you go to tools > synchronize now
    You can check the timestamp of the last synchronization status in the topic: config page one and find the last sync, and there will be a timestamp it. Firefox Sync troubleshooting and tips for more information.

  • How will I know if the history has been erased?

    Of course, if the whole story is off, you know. But because FF provides partial compensation, how do I know if this has been done? I know I need probably better parental controls in place; This is a problem. But still, I would like to know how do I know if the story is partially cleared.

    You can not. If you want to keep track of the Web sites that are visited, then you need to install a program like netnanny to control this traffic.

  • How will I know that the synchronization completed successfully and that it is prudent to close the browser?

    I'm working on my desktop PC or on my laptop. The latest Firefox is installed on both computers (FF10.0)

    (1) I don't know if I start synchronization manually (Tools/sync now) or if this is supported automatically on an ongoing basis.

    (2) in any case, how can I know when the synchronization completed successfully, and it is prudent to close the browser.

    I don't want to meet me on the road with my latest password updates or missing bookmarks.

    I do not see in the status information about the synchronization process. It is very disturbing and not exactly which involves trust.

    Your
    John

    Maybe check the synchronization log on the subject: a sync-log page

    You can open on: xxxx pages through the bar of addresses as you open a Web site.

  • How will I know when the capsules are on?

    Original title: caps Inspiron 1545?

    How will I know when the capsules are on?

    Hey, Vince,.

    Caps lock key are you referring?

    If you look above the keyboard on the right, you will see two fires instead of one.

    In addition, you will type in uppercase when the key is turned on

  • How will I know if the update of the firmware which is due a minuite was released?

    How will I know if the update of the firmware which is due a minuite was released?

    And how do I know the improvements and stuff?

    Thank you

    SR

    SR - rox wrote:

    How will I know if the update of the firmware which is due a minuite was released?

    And how do I know the improvements and stuff?

    Thank you

    SR

    The new firmware is displayed in the thread to update the Firmware Sansa Fuze, which will be reset and cleaned. The change log will be part of the first post in this same thread. In addition to this it will be impossible to miss. People will speak on this subject.

  • How do you know if the hard disk controller is damaged or it does not work?

    Hello

    I would like to know how you can know if the hard disk controller is defect.  is there some tools for it or a way to test it.

    I have thouthg my self for a solution like this;

    -If I take the hard drive that is not working out pc and attach it to the speaker and the speaker set on a PC then I wil first hear the rotation of your drive hard so that when the PC wil recognizes the external hard drive as a hard disk and then the controller is OK, otherwise it means that the controller is damaged.

    . I know mechanical problems with a hard disk, they do some sounds when they turn.

    is the way I think it is the right way to know or there is much better way to find out if there is a problem with the hard disk controller.

    Thank you

    Johan

    Small circuit board is an interface for cables that sorts what is happening in the place where. It holds the drive buffer and it tells the computer what it is, i.e. drive, speed, brand, model, size etc.

    If you get an error of hard disk controller, it's a motherboard problem and there is no way to fix it.

    Hard drives fail for two reasons...

    1. The platters inside are deteriorating to the point where they are no more able to maintain the structure of the sector/cluster.
    2. The spindle motor breaks down.

    The part of a disk hard less likely to fail is the interface card, unless he is accidentally cut on the computer case or other metallic surface. If this short, you will know that the smoke resulting hard disk is acrid beggars belief. It is almost the only case where the interface will fail.

    Even when a hard drive is subjected to temperatures beyond its limits, the spindle motor bearings will fail way before anything else, that's why the vast majority of the disk hard total fails is obvious because there is no vibration of the engine.

    If a hard drive starts to cause problems, it is best to replace it because it will always get worse over time...

  • How do I know if the program is compatible with my operating system?

    How will I know if a program I want to install is not compatible with my windows operating system

    See the developers website for compatibility with Windows 7 and if there are updates, corrections or difficulties that might ensure compatibility.

    Windows 7 Compatibility Center

    Check if your application software or hardware is on the list

    http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/default.aspx

    Software:

    http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/default.aspx?type=software

    You can also try to run the program in compatibility mode

    You can find more information on compatibility modes in the articles below:

    http://Windows.Microsoft.com/en-us/Windows7/what-is-program-compatibility

    http://Windows.Microsoft.com/en-us/Windows7/make-older-programs-run-in-this-version-of-Windows

    http://Windows.Microsoft.com/en-us/Windows7/Program-Compatibility-Assistant-frequently-asked-question

    The software is designed for an earlier version of Windows such as Windows XP? Most older programs don't work with Windows 7, in particular some programs for Windows XP, can you need to perhaps upgrade to Windows 7 Professional or ultimate edition if you run not an edition and download the Windows XP Mode free program which will allow you run old programs:

    Run in Windows XP Mode requires:

    (1) Windows 7 Professional, Ultimate or Enterprise (not supported in Home Premium).

    Windows XP Mode and Windows Virtual PC

    http://www.Microsoft.com/Windows/Virtual-PC/default.aspx

    Windows XP Mode now accessible to more than PC

    http://windowsteamblog.com/Windows/archive/b/Windows7/archive/2010/03/18/Windows-XP-mode-now-accessible-to-more-PCs.aspx

    Get started with Windows Virtual PC

    http://www.Microsoft.com/Windows/Virtual-PC/get-started.aspx

    http://www.notebooks.com/2009/11/23/using-Windows-Virtual-PC-with-Windows-XP-mode/

    Windows 7 - upgrade Express features:

    http://Windows.Microsoft.com/en-us/Windows7/products/features/Windows-Anytime-Upgrade

Maybe you are looking for