[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ' '.

S

Srinivas

Hi,
I am working on a project to script all database objects.The code
below works fine on my machine( windows XP ) and all the creates all
the db objects.

But I get an error message when I run it on a server( windows server
2003).

The first part of the code where I am executing sp_dboption and
getting all the options set for the database is working fine and it
creates the required script , but the piece of code using the SQLDMO
to get the database objects is where I am getting the error.

Thanks

Srini



Code Listing :-

public class ScriptAndCreateDataBases
{
public void ConnectAndScriptDatabases( SQLServer2Class server )
{

server.LoginSecure = true;
server.Connect( server.Name , "sa" , "" ) ;

- - - -
foreach (Database2 d in databases )
{

ConnectAndGetOptions( server , d.Name, options);
ScriptDBObjects dbobj = new ScriptDBObjects();
dbobj.Initialize(server, d);
}

- - - -


public class ScriptDBObjects
{
private SQLServer2Class m_sqlserver;
public void Initialize(SQLServer2Class ssc , Database2 db )
{
m_sqlserver = new SQLServer2Class() ;
m_sqlserver = ssc ;
---
}

private void ScriptDatabase(Database2 db , SQLServer2Class server
{
case Db_Types.Defaults:
s_transfer.CopyAllDefaults = true;
GenerateScript(s_transfer, workingFolder, db );
}

private void GenerateScript(TransferClass tc, string folder, Database2
db )
{

--erroring out db.ScriptTransfer(tc,
SQLDMO_XFRSCRIPTMODE_TYPE.SQLDMOXfrFile_SingleFilePerObject, folder);
}
 
M

Marc Scheuner [MVP ADSI]

But I get an error message when I run it on a server( windows server
2003).

server.LoginSecure = true;
server.Connect( server.Name , "sa" , "" ) ;

Most likely, your server's SQL database is protecting the "sa" account
(System Administrator) with a password..... that's why your login
fails (I think).

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top