Wednesday, August 22, 2007

Kudos MediaMax !!!

MediaMax users have been facing problems with their accounts for sometime now.
I too couldn't access any of my files.....TILL TODAY!
How happy I am to see all my pics and programs back online!!
MediaMax rocks!

SqlDependency not firing

Grrrr...after hours of trying various pieces of C# code and tinkering with SQL Server 2005 settings it turns out that the database owner was the problem.

class Program
{
static string connStr = "Server=DARKSTAR; Initial Catalog=MyDatabase; Integrated Security=false; User Id=sa; Password=XXXXXXXXXX";

static SqlDependency dep;

static void Main(string[] args)
{
SqlDependency.Start(connStr);
TestSqlNotificiation();
SqlDependency.Stop(connStr);
}

static void TestSqlNotificiation()
{
try
{
using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();

SqlCommand cmd = conn.CreateCommand();

cmd.CommandText = "Select RollNo, [Name] from dbo.Students";

dep = new SqlDependency(cmd);

dep.OnChange += new OnChangeEventHandler(OnDataChange);

SqlDataReader dr = cmd.ExecuteReader();
{
while (dr.Read())
{
Console.WriteLine("Name = " + dr[1].ToString());
}
}

dr.Close();

Console.WriteLine("Waiting for any data changes...\nPress to end program.");
Console.ReadLine();
}
}
finally
{
//SqlDependency.Stop(connStr);
}
}

static void OnDataChange(object sender, SqlNotificationEventArgs e)
{
Console.WriteLine(e.Info.ToString());
Console.WriteLine(e.Source.ToString());
}
}
}

This is the program which should fire the OnDataChange function when rows change in the Students table. However, the event was simply not firing.

Finally I chanced upon this article which made everything work right. It turned out that I was having problems with the database owner. I just changed it to 'sa' for the time-being:

ALTER AUTHORIZATION ON DATABASE::MyDatabase TO sa;

Wednesday, August 15, 2007

SQL Server 2005 Express Advanced Edition reports AGTACCOUNT error during Setup

SQL Server 2005 Express Advanced Edition reports following error during setup:

"SQL Server Setup has determined that the following account properties are not specified: 'AGTACCOUNT' . The properties specify the startup account for the services that are installed. To proceed, refer to the template.ini and set the properties to valid account names. If you are specifying a windows user account, you must also specify the password for the account."

After trying some of the stuff mentions at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=365116&SiteID=1 I finally gave up.

But wait a minute, there was something about a template.ini file.
This is what I did and it worked. First copy the install files from your Read-Only media (CD/DVD) to a folder on your hard-drive. Open the template.ini file (directly under the root folder containing the setup files).

Look for the following section:

; Note that if SQLBrowser is already installed, SQLBROWSERACCOUNT and SQLBROWSERPASSWORD are ignored.

SQLBROWSERACCOUNT=
SQLBROWSERPASSWORD=

SQLACCOUNT=
SQLPASSWORD=

AGTACCOUNT="NT AUTHORITY\NETWORK SERVICE"
AGTPASSWORD=

ASACCOUNT=
ASPASSWORD=

RSACCOUNT=
RSPASSWORD=
;--------------------------------------------------------------------
; To use the *AUTOSTART features, specify 1 to start automatically or 0 to start manually.

See the bolded line, all you need to is specify the account for it and then launch setup.exe with the following parameters:
setup.exe /settings c:\template.ini

Looking at the command line, it seems likely that you could get away by copying and editing just the template.ini file instead of all the installation files to hard-disk.