المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : SQL 2005 connection failed



C# Programming
08-05-2009, 10:11 AM
I have a SQL 2005 server using the following parameters
DBName=MyDatabase
user: joe123
passwrod:sm123
joe123 is teh MyDatabase owner

I want to connect to the DB, find out the status and display it in textBox6.

The problem is that the "try" block is not executed. Error with access deny.

If I run c:\oslp -Ujoe123 -Psm123 -Slocalhost\SQLSRV--it works


conStr ="user id=joe123;password=sm123;server=localhost\\SQLSRV;Trusted_Connection=yes;database=MyDatabase; connection timeout=30";
SqlConnection conn= new SqlConnection(conStr);
try
{
conn.Open();
SqlCommand thisCommand = conn.CreateCommand();
thisCommand.CommandText = "SELECT DATABASEPROPERTYEX(‘ctxima’, ‘Status’) DatabaseStatus_DATABASEPROPERTYEX";
Object dbStatus = thisCommand.ExecuteScalar();

}
catch (System.Exception excep)
{
MessageBox.Show(excep.Message);
textBox6.Text=dbStatus
}

ANY HELP IS GREATLY APPRECIATED