none
SQL Server Access denied error for SS 2000 in VS2003 RRS feed

  • Question

  • Hi,

     

    I am using VS 2003 and trying to connect to a SQL Server 2000 database. Everytime I do I get a "SQL Server does not exist or access denied" error.

     

    I have checked and doule-checked my Server Name, Login, etc. and they seem to be correct. I can create a new connection under Data Connections on the Server Explorer tab. I can also connect to the database using Enterprise Manager - all with the same password, user ID, etc.

     

    Any idea (assuming I typed the passwords, database, etc. correctly) why I cannot connect through code but I can using the Add Data Connection wizard?

     

    Thank you.

     

    Below is my code:

     

    Code Snippet

    public DataTable GetDataSQLServer()

    {

    string ServerName = "ReportServer";

    string Database = "MyReportDatabase";

    string LoginID = "MyLogin";

    string Password = "myPassword";

     

    string tableName = "tblStandardReports";

     

    String connectionString = String.Format("server={0};database={1};uid={2};pwd={3};",ServerName, Database,LoginID,Password);

     

    String SQLQuery = String.Format("Select * from {0}", tableName);

    SqlDataAdapter dataAdapter = new SqlDataAdapter(SQLQuery, connectionString);

    SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

     

    DataSet ds = new DataSet();

    dataAdapter.Fill(ds,tableName);

    return ds.Tables[0];

    }

     

     

    Monday, January 28, 2008 8:16 PM

Answers