SMO question: Cannot attach database using captured SQL

Hi,
I have the following code
ServerConnection conn = new ServerConnection(".\\SQLEXPRESS");
Server svr = new Server(conn);
svr.ConnectionContext.SqlExecutionModes = SqlExecutionModes.CaptureSql;
StringCollection sc = new StringCollection();
sc.Add(Smo.DatabaseFilePath);
sc.Add(Smo.DatabaseLogPath);
svr.AttachDatabase(Smo.DatabaseFilePath.ToUpper(), sc, AttachOptions.None);
int[] results = svr.ConnectionContext.ExecuteNonQuery(svr.ConnectionContext.CapturedSql.Text);
svr = null;
conn.Disconnect();
conn = null;
It works fine if I call svr.AttachDatabase(Smo.DatabaseFilePath.ToUpper(), sc, AttachOptions.None) directly without going through the captured SQL.
Any ideas why?
Thanks in advance.

Hi superflyguy71,
Please , could you tell what you mean with these both code lines ?
sc.Add(Smo.DatabaseFilePath);
sc.Add(Smo.DatabaseLogPath);
I don't know any class or property named DatabaseFilePath or DatabaseLogPath in the namespace Microsoft.SqlServer.Management.Smo in any version of Smo since its creation ( 2005 )
Compare
http://msdn.microsoft.com/en-US/library/ms210175(v=sql.90).aspx and
http://msdn.microsoft.com/en-US/library/ms210175(v=sql.120).aspx
I am not sure that this code could even be compiled with errors.
Have a nice day
PS : I would suggest you to have a look at this old thread ( with no use of AttachOptions )
http://social.technet.microsoft.com/Forums/sqlserver/en-US/b8e80512-c3be-4048-b633-f9b1dc36c8b4/c-smo-attach-sql-database-fails-console-application?forum=sqlsmoanddmo
Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

Similar Messages

  • I cannot attache files using Firefox for Hotmail or Yahoo - IE works - help!

    Wed night 3/2 and this am 3/4 cannot attach any files pdf or doc while using Firefox in my Hotmail or yahoo email accounts. I did a virus speep and none was found. I opened internet explorer on the same home computer and was able to attach the files via my email accounts. Any help?

    You have a lot of changes to your setting in the network.http section. These are listed in the More System Details list to the right of your question under "Question Details". Do you recall making those changes, or did you use some kind of browser speedup or tuning software that could have done it?
    To test how Firefox runs "uncustomized" on your system, could you do a two-minute experiment?
    '''Create a new Firefox profile'''
    A new profile will have your system-installed plugins (e.g., Flash) and extensions (e.g., security suite toolbars), but no themes, other extensions, or other customizations. It also should have completely fresh settings databases and a fresh cache folder.
    Exit Firefox and start up in the Profile Manager using Start > search box (or Run):
    firefox.exe -P
    Any time you want to switch profiles, exit Firefox and return to this dialog.
    You'll click the Create Profile button. I recommend using the default location suggested (don't click the button to choose a different folder). Then start Firefox in the new profile you created.
    Do sites work more normally?
    When returning to the Profile Manager, you might be tempted to use the Delete Profile button. But... it's a bit too easy to accidentally delete your "real" profile, so I recommend resisting the temptation. If you do want to clean up later, I suggest making a backup of all your profiles first in case something were to go wrong.

  • How to connect database using oracle SQL developer

    Hello
    I am newbie in EBS R12
    I downloaded Oracle SQL Developer
    and create new database conenction
    Connection name: ebs demo db connection
    username:
    password:
    Role: Default
    Connection type: Basic
    Hostname: ebstailin.demo.com
    Port: 1521
    SID: clone
    when i try this there is an error
    Status: Failure-Test failed: lo exception: The Network Adapter could not establish the connection
    no idea about this
    but i used the apps/apps as username and password
    please help
    thanks
    Edited by: cheesewizz on Jul 16, 2010 11:35 PM

    Hello
    Thanks for your reply
    I tried to connect and here is the result: see below
    [oracle@ebstailin 11.1.0]$ sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.7.0 - Production on Sat Jul 17 15:35:31 2010
    Copyright (c) 1982, 2008, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> CONNECT apps/apps
    Connected.
    SQL>
    But still cannot connect using ORACLE SQL Developer
    thanks

  • Cannot attach database

    Hi!  We have an old SQL 2007 database on a Windows 2000 machine that's dieing.  I can't load any of the SQL tools on that machine or connect to it externally.  So I copied off the .mdf and .ldf files to a folder on my machine (Win7). 
    I installed SQL Server 2012 Express and connect with Management Studio.  I choose the "Attach" function and a dialog appears allowing me to select the database file.  I choose "Add...", select the .mdf file and... nothing. 
    No errors and nothing appears in the dialog like I didn't do a thing.
    Any ideas?
    Thanks!

    You cannot attach old database directly to SQL 2012. Please upgrade to any intermediate SQL versions before upgrading it to SQL 2012.
    Refer below link for more information
    http://technet.microsoft.com/en-us/library/ms143393(v=sql.110).aspx
    QL Server 2012 supports upgrade from the following versions of SQL Server:
    SQL Server 2005 SP4 or later
    SQL Server 2008 SP2 or later
    SQL Server 2008 R2 SP1 or later
    BTW, what is the correct old SQL database Version?
    --Prashanth

  • Unable to connect to Oracle Database using Oracle Sql developer 2.1.1.64

    Hi Everyone,
    I am searching for some help regarding my problem with Oracle connectivity. I have installed Oracle 11g release 2 on my Windows XP Professional Laptop. For a few days after installation i could connect to the Oracle database with the SYSTEM account using Oracle SQL developer ( installed on the same Laptop) but now i am unable to do so.It gives me this annoying message:
    An error was encountered performing the required operation  Got a minus one from read call .Vendor code 0
    However i am able to connect using Sql Plus by supplying the username SYSTEM and the corresponding password.
    My TNSNAMES .ora file is as follows:
    ORACLE =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = ORACLE)
    ORACLR_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (CONNECT_DATA =
    (SID = CLRExtProc)
    (PRESENTATION = RO)
    My Listener.ora file is as follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = CLRExtProc)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ONLY:D:\app\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    (SID_DESC =
    (GLOBAL_DBNAME = Oracle)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (SID_NAME = Oracle)
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (PROTOCOL_STACK =
    (PRESENTATION = GIOP)
    (SESSION = RAW)
    ADR_BASE_LISTENER = D:\app
    My Sqlnet.ora file is as follows:
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
    I am new to Oracle and so i need someone in this forum who can help me resolve this problem. Also i even tried connecting to the database using Toad 10.5.0.41. It give me the following error:
    ORA 12537 : TNS Connection closed
    Thanks for your patience and help in advance.
    ---Prashant

    Hello Irian and Sue,
    I can connect to the Oracle database using SQL Plus. Now when i TNSPING ORACLE from command line i get the following message :
    Used parameter files:
    D:\app\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =localhost
    *)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORACLE)))*
    TNS-12537: TNS:connection closed
    Thanks for your response to my initial post.Do u have any other methods to resolve this?

  • HOW TO START MAKING DATABASE USING ORACLE SQL PLUS in 10g?

    how will i create database using sql plus?
    does the code of sql applicable to it..?
    do i have to use the "create db <database name>", use and " create table also,.."
    pls help me..
    thanks

    At dos prompt :
    C:\>set ORACLE_SID=<your SID>
    C:\>sqlplus / as sysdba
    you get connected as sys user. Don't use this connection to create your own objects, create users instead.... but it would be useful to read some documentation, for example Starting SQL*Plus and manuals mentioned there.

  • Search for tablenames in the database using native sql query script

    How do i search for the names of the tables in the database using select statement? I do not know the names of the tables but I know the name of the database and i do not have the sys priviliges.
    thanks
    SS

    SELECT owner, table_name
    FROM all_tables;

  • Cannot send email using PL/SQL through Enterprise Manager 10g

    Hi
    I need to schedule a job that sends email periodically. I am using the scheduler in Oracle Enterprise Manager 10g for this. For sending the email, I am creating a PL/SQL job. The code is as follows:
    PROCEDURE send_test_message
    IS
    mailhost := 'iwblrcormsg001.sci.local';
    sender := '[email protected]';
    recipient := '[email protected]';
    mail_conn utl_smtp.connection;
    BEGIN
    mail_conn := utl_smtp.open_connection(mailhost, 25);
    utl_smtp.helo(mail_conn, mailhost);
    utl_smtp.mail(mail_conn, sender);
    utl_smtp.rcpt(mail_conn, recipient);
    utl_smtp.open_data(mail_conn);
    utl_smtp.write_data(mail_conn, 'This is a test message.' || chr(13));
    utl_smtp.write_data(mail_conn, 'This is line 2.' || chr(13));
    utl_smtp.close_data(mail_conn);
    utl_smtp.quit(mail_conn);
    END;
    I have setup the smtp server and received a test email from the EM notifying me of successful configuration. When the above job is run, the scheduler shows status as successful. If I go to the command step, it displays the following output:
    Output Log
    SQL*Plus: Release 10.1.0.2.0 - Production on Thu Feb 19 19:04:29 2009
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    SQL> SQL> SQL> SQL> Connected.
    SQL> SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Disconnected from Personal Oracle Database 10g Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Now, the only issue is that I do not receive any email at the address specified! I would be very grateful if someone could point out the error here.

    I would use APEX4.0 for this.
    Create an interactive report based on your data. Add a chart to that report and use the NOTIFY feature to send you the email.

  • Issues connecting to sql 2005 database using Oracle sql developer 1.2

    I just installed the sql developer and was trying to use the quick migrate to try a migration from a sql server to oracle..
    I am getting the following error message when i click on the retrieve database after entering the database credentials
    Status : Failure net.sourceforge.jtds.jdbc.driver
    I am getting another error message when i click on the 'test' button
    Status: Failure - Unable to find driver: net.sourceforge.jtds.jdbc.driver
    I downloaded the jtds driver from source forge and i am wondering what I should do to get the sql developer to make successful connections to sql server.
    Any help is appreciated.
    Thanks

    I have the same issue with both version 1.1.3 of the SQL developer and the latest version(1.2.1). I have added the jar file path in tools->preferences->Database->Third Party etc...
    I got the jar file from this download: jtds-1.2.2-src.zip
    I get this error when trying to connect to an sql server:
    oracle.jdeveloper.cm.CMException: Unable to find driver: net.sourceforge.jtds.jdbc.Driver
         at oracle.dbtools.raptor.conntypes.RaptorConnectionWrapper.createConnection(RaptorConnectionWrapper.java:175)
         at oracle.dbtools.raptor.conntypes.RaptorConnectionWrapper.getJdbcConnection(RaptorConnectionWrapper.java:202)
         at oracle.dbtools.raptor.conntypes.RaptorConnectionWrapper.getPresentation(RaptorConnectionWrapper.java:68)
         at oracle.dbtools.raptor.utils.Connections$ConnectionInfo.createConnection(Connections.java:1004)
         at oracle.dbtools.raptor.utils.Connections$ConnectionInfo$ConnectRunnable.doWork(Connections.java:876)
         at oracle.ide.dialogs.ProgressRunnable.run(ProgressRunnable.java:159)
         at oracle.ide.dialogs.ProgressBar.run(ProgressBar.java:553)
         at java.lang.Thread.run(Thread.java:595)
    Any help would be appreciated. I like the tool would hate to have to abandon it, it works like a charm on our oracle databases.

  • Create a copy of active database using T-SQL.

    I have a requirement to create a copy of existing active (currently in use) database through code.
    I need to copy all objects which include tables, stored procs, triggers, functions, foreign keys, constraints, primary keys, etc... from source DB to new DB.
    Both databases can be in different servers where I have access to both the servers. I also need to copy data for some tables....
    It is exactly what copy database wizard is doing... but I want to do it through T-SQL code.....
    is it possible?

    This doesn't sound like too easy task. I tried to search, but the best I found so far was Freeware SQL Script Generate utility
    I do have a blog to generate all stored procedures
    How to script all stored procedures in a database
    but this is only a small part of the task. Brad Schulz has a blog to generate table creation/insert statements. I don't remember seeing the complete free T-SQL solution for all SQL Server database objects.
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth
    Naomi Nosonovsky, Sr. Programmer-Analyst
    My blog

  • How to create a database using a SQL statement? Please help.

    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.25:1521:mydb","system","12345678");
    but mydb database does not exist.
    I want to make a connection to oracle server without database name.
    How can I do?

    Colleauge, what is the purpose of making a connection to a non-existent database.
    connections are made to the database to retrieve some data or put some data.
    for which the database should exists.
    so please create the mydb database first using Database Configuration Assistant (DBCA) which is much easier as it is GUI based rather than doing it with sql scripts.

  • Updating a database using XML SQL Utility

    Hi all,
    It seems that the Oracle XML SQL Utility provides only to insert rows into a table/view. However, if one wants to update a table from an XML no support is available.
    How does one proceed if this is to be achieved?
    Thanks in advance.
    Regards,
    Manoj
    null

    While inserting i get a
    oracle.xml.sql.OracleXMLSQLException and further a
    NumberFormatException. Which parameter do I have to set to avoid
    these Exceptions. I can insert the file in my local db but I get
    the Exception on the server db. The value I want to insert for
    expample is 30,1. Maybe the JDBC-Driver tries to convert the String ;30,1+ to an
    Integer-Object. This will cause the described Exception since
    the Integer-Class requires ;.+ instead of ;,+ for decimal point.
    I have another problem generating an xmlfile when there
    are "Umlaute" in the data. E.g. V and \. Exchanging these to Oe
    and Ue than it works fine.Use ISO-8859-1 character set to work with umlauts, e.g.:
    <?xml version = '1.0' encoding = 'ISO-8859-1'?>
    .. but you can use the default UTF-8 encoding too, umlauts will
    be replaced by equivalents as ;C&#376;+
    Alex

  • Take offline and then detach Database. Won't let me attach Database back into SQL Server...

    Hi, Read some other posts, but couldn't get it to work. Thanks in advance, Here is the error notice:

    Make sure to run SSMS as Admin if you're using SQL Server 2012. 
    It is indeed the known issue and running SSMS as Admin should solve it.
    BTW, this solution I found in www.universalthread.com forum. I re-checked these threads if they contain any supporting links, but no. In any case, that solution helped that person and myself as well.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Same old question  (rows to columns using pl/sql)

    Hi all,
    i am re-posting the same requirement, please do the needful.
    I need a query to convert row value into column delimited by space.
    Dont need any column names just values.
    create table tb_row_2_col (id number,val varchar2(100));
    insert into tb_row_2_col values (1,'col1');
    insert into tb_row_2_col values (1,'col2');
    insert into tb_row_2_col values (1,'col3');
    insert into tb_row_2_col values (2,'col4');
    insert into tb_row_2_col values (2,'col5');
    commit;
    SQL> select * from tb_row_2_col;
    ID VAL
    1 col1
    1 col2
    1 col3
    2 col4
    2 col5
    SQL>
    if i execute a query the output should be like this. Please dont used decode/case.
    need to use loop to do the needful.
    1 col1 col2 col3
    2 col4 col5
    Priya.

    I doubted PL/SQL will be much faster, bjut here it goes:
    declare
        v_id number;
        v_prev_id number;
        v_val varchar2(100);
        v_combined_val varchar2(4000);
        cursor v_cur is select id,val from tb_row_2_col order by id,val;
    begin
        open v_cur;
        fetch v_cur into v_prev_id,v_combined_val;
        loop
          fetch v_cur into v_id,v_val;
          exit when v_cur%notfound;
          if v_id = v_prev_id
            then
              v_combined_val := v_combined_val || ' ' || v_val;
            else
              dbms_output.put_line(rpad(v_prev_id,5) || v_combined_val);
              v_prev_id := v_id;
              v_combined_val := v_val;
          end if;
        end loop;
        dbms_output.put_line(rpad(v_prev_id,5) || v_combined_val);
        close v_cur;
    end;
    1    col1 col2 col3
    2    col4 col5
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Cannot attach photos using Yahoo mail ... always could before your last upgrade. that seems like a downgrade to me.

    I can no longer attach photos of docs using yahoo mail since new upgrade. why not and what can I do to fix this. attachments are a very integral part of the e-mail functionality. what have you guys done? how is this fixed?

    ajosephine wrote:
    If u noticed it b4 ur new billing cycle, if u beg hard enuff they might credit u for half. I think as an act of kindness they cud reach out to u and let u kno ur over ur minutes. Yes u can check constantly, but sometimes u may not realize it cuz things happen. Its not really about fault it wud b good customer care to go that extra mile, and they cud probably use that to charge u for there kindness.
    For those who find this incredibly painful to read,
    If you noticed it before your new billing cycle, if you beg hard enough they might credit you for half. I think as an act of kindness they could reach out to you and let you know you're over your minutes. Yes you can check constantly, but sometimes you may not realize it because things happen. It's not really about fault it would be good customer care to go that extra mile, and they could probably use that to charge you for their kindness.

Maybe you are looking for

  • I cannot find the app i just installed on my ipod touch

    I just baught the new ipod touch today and the first app i downloaded was facebook, however, i cannot find it on my ipod now, it says in the app store thats facebook has already been installed but i cannot find it. is there anything i can do?

  • How do archive all messages over 5yrs old for easy access if needed

    My Thunderbird folders are very large after 10 years and I have over 100 sub-folders. I need to keep all messages but would like to keep the oldest, say over 5 years old, separate as I rarely need to see them again. Archiving would make navigation ea

  • "Login Options" in "System Preferences"- Accounts gone.

    Hello, on some of our machines the "Login Options" can not be clicked any more. These machines are special: - They came preinstalled (and or are freshly installed) with Leopard - They are mostly Laptops without Network-homedirectories - They have (so

  • Open all files in folder using Javascript

    Let's say I want to open all the files in a particular folder, without knowing the names of those files. Any ideas? Thanks!

  • Want to factory unlock my iphone 4g

    i want to factory unlock my iphone 4g 32gb.. i bought it from america, now am in london permantly.. my imei number is 01241800739426.please help me out.thank you