By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,288 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,288 IT Pros & Developers. It's quick & easy.

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

P: n/a
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_SingleFile PerObject, folder);
}
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
>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
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more C# / C Sharp Questions on Bytes