Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Tuesday, March 31, 2009

SQL Server 2005 database diagram support objects error

Sql 2005 Database diagram support objects cannot be installed because this database does not have a valid owner...

Solution:
1. Right Click on your database, choose properties
2. Goto the Options Page
3. In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
4. Goto the Files Page
5. Enter "sa" in the owner textbox.
6. Hit OK

Reference: http://geekswithblogs.net/shahed/archive/2007/11/19/116940.aspx

Thursday, March 19, 2009

Incorrect Syntax Near sproc ...

I got this 'incorrect syntax near spoc (stored procedure)' error from the following:

string connectionString = getConnectionString("ConnectionString");
SqlConnection conn = new SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("sproc_aspnet_StocksInLists_RemoveStocksFromList", conn);

try
{
conn.Open();
command.Parameters.AddWithValue("@ListId", ddlList.SelectedValue);
iRes = command.ExecuteNonQuery();
if (iRes < 0) throw new Exception("Error removing stocks from list");
}
The bug fix is to set the command type:

string connectionString = getConnectionString("ConnectionString");
SqlConnection conn = new SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("sproc_aspnet_StocksInLists_RemoveStocksFromList", conn);
command.CommandType = System.Data.CommandType.StoredProcedure;
try
{
conn.Open();
command.Parameters.AddWithValue("@ListId", ddlList.SelectedValue);
iRes = command.ExecuteNonQuery();
if (iRes < 0) throw new Exception("Error removing stocks from list");
}