0
Reply

Clone SQL 2008 R2 database

Massimo

Massimo

Oct 19 2012 2:10 AM
12.6k
Hi to all and sorry for my english,
here my code to clone SQL db. Starting from .sql base file, i change db name and run script. Accepting any suggestion about this code, i explain my issue.

I write code in my develop machine with VS2010 and cassini web server. This pc is joined in mydomain and i login (and work) with domain user "admin". Also SQL server mysqlserver is joined in domain. User admin have dbcreator, public and sysadmin rule on this SQL server.

Now, if i run webpage in my develop machine, all work fine and db is created as desidered.

Issue born when i publish page in W2008 web server (IIS 7). This server is joined in domain and is in LAN with develop machine and mysqlserver.

Web page stop with

Object reference not set to an instance of an object


After some test i understand the issue is caused by this row

server.ConnectionContext.ExecuteNonQuery(script);


My test before write this post:
- run this row inside try/catch. Nothing change and no exception is generated.
- run with another (domain admin) elevated user. Nothing change
- run with a sample SQL query (select * from testdb). Nothing change

How i can approach this (for me) very strange issue?

I hope to be clear in my explanation.

Thanks in advanced for any help.

Regards.

Massimo

Attachment: source.zip