Attach Database Problem

  • 9 years ago

    hi all,

    I am getting a problem in attaching a database to my sql server 2005. The error is: "Attach Database failed for server 'MYSERVER' ".

    The code I am using is:

     

    server srvr = new server();

    stringcollection paylogpath= new stringcollection();

    paylogpath.add("~/payroll.mdf");

    srvr.attachdatabase("payroll", paylogpath);

    IF I USE FULL PATH OF THE 'payroll.mdf' THEN I AM ABLE TO ATTACH THE DATABASE, BUT PAYROLL.MDF IS IN MY APP_DATA FOLDER AND I WANT TO USE IT DIRECTLY, HOW CAN I DO THAT?

    can anyone guide me where I am going wrong.

    Regards.

    Royal

  • 9 years ago

    hi Naresh,

    I have earlier tried this also.......but it doesn't work..gives the same error. The only time I got success was when I use the whole path i.e. from C:/.........../paroll.mdf. Even I tried using mappath and application path..........but not happening...........again same error.

    Regards,

    Royal

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An idiot with a computer is a faster, better idiot” - Rich Julius