On Sat, Dec 4, 2010 at 9:54 AM, Ian <[email protected]> wrote: > Hi all, > > Being new to Visual Studio 2010 c#, I am trying to get to grips with > the basics. The following code > errors when running a script from sql server 2008 to create tables > against an existing database. the script does run ok if ran from, > within sql server 2008. > > The code in my c# app taken from on line examples states; > > string script = File.ReadAllText("C:\\Temp\\script.sql"); > Microsoft.SqlServer.Management.Smo.Server server = > new Microsoft.SqlServer.Management.Smo.Server(); > server.ConnectionContext.LoginSecure = false; > server.ConnectionContext.Login = UserId.Text; > server.ConnectionContext.Password = UserPw.Text; > server.ConnectionContext.ServerInstance = > SvrName.Text; -----------------------------
Does the table exist already in the db? Do the UserID/PW have rights to make table as dbo? I will guess that it is a security issue first or an error in the attempted code. The object already exists, the alter statement is not allowed, .... HTH -- Stephen Russell Sr. Production Systems Programmer CIMSgts 901.246-0159 cell
