Are you getting this excepton you attempt to attach a database (.mdf) file using your MS SQL Server 2005 management studio?
Create failed for Database 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer$SQLSERVER2005.mdf'. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ReportServer$SQLSERVER2005.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5118)
The links below will take you to useful blogs on the causes of this exception. I will not bother to repeat the causes
but give you a quick walk around to resolving.
http://blogs.msdn.com/sanchan/archive/2006/06/04/617585.aspx
http://blogs.msdn.com/sqlblog/archive/2006/10/02/SQL-Server-databases-are-not-supported-on-compressed-volumes.aspx
I hardly found a simple approach to resolving this issue. I used compact/u in my Command Prompt but no joy. Eventually, this is what i try out on my system and it works. See if it will work for you too.
STEPS
1. Go to the file path of the .mdf file. Usually, it is "C:\Program Files\Microsoft SQL Server\MSSQL.1
\MSSQL\Data\ReportServer$SQLSERVER2005.mdf"
2. Right click on the .mdf file and click Properties.
3. When the Properties dialog box opens, click Advanced button
4. On the Advanced Attributes box, uncheck 'Compress contents to save disk space'.
5. Click Ok twice to exit the Properties box.
6. Go through steps 1 - 5 to decompress the log file (.ldf) associated with the .mdf file.
7. Now, try attaching the .mdf file again. It'll work!
Wednesday, October 29, 2008
Monday, October 27, 2008
Setting ListView Columns dynamically in Windows Mobile Applications
Hardcoding values into source code is never advised. It is particularly instructive in a windows mobile application as far as one is concerned about the various devices on which windows mobile OS runs. These devices have varied screen sizes and making your application adaptive to each device is definitely a show of good programming.
A good scenario for this is using ListView control to display records. It is easy to set the ListView columns to fit the screen of the Emulator or device you are using for your testing during development. That is called hardcoding. What happens after deployment to other devices? Granted, the ListView horizontal and vertical scrollbar will automatically help with rendering each row of record. But it may not be what you want as users will have to move back and forth unnecessarily. Or it may be needless since the rendering could have been more proper if the columns have been set dynamically.
The .NET GUI controls have Anchor property which can be used to stretch and adapt the ListView size to your device screen size. It is ok if your ListView has only one column. But what if there are 2 or more columns and column width ought to be allocated according to a pre-set ratio?
The code snippet below demonstrates how to dynamically set the columns width of a ListView at runtime. The logic is to allocate a percentage of the ListView control to each column. You can be sure that this logic, along with setting the Anchor property of the control to the right will always give your control a better rendering.
ListView1.Columns.Clear();
float fWidth ;
ColumnHeader colTo = new ColumnHeader();
colTo.Text = "Name";
fWidth = (0.38F * ListView1.Width);
colTo.Width = (int)fWidth;
ColumnHeader colMessage = new ColumnHeader();
colMessage.Text = "Number";
fWidth = (0.55F * ListView1.Width);
colMessage.Width = (int)fWidth;
//add the columns
ListView1.Columns.Add(colTo);
ListView1.Columns.Add(colMessage);
The two columns are allocated 38% and 55% respectively. The remaining 7% is an allowance for Vertical scrollbar so that Horizontal scrollbar will not appear automatically. I personally dislike having both bars on my ListView control.
Hardcoding values into source code is never advised. It is particularly instructive in a windows mobile application as far as one is concerned about the various devices on which windows mobile OS runs. These devices have varied screen sizes and making your application adaptive to each device is definitely a show of good programming.
A good scenario for this is using ListView control to display records. It is easy to set the ListView columns to fit the screen of the Emulator or device you are using for your testing during development. That is called hardcoding. What happens after deployment to other devices? Granted, the ListView horizontal and vertical scrollbar will automatically help with rendering each row of record. But it may not be what you want as users will have to move back and forth unnecessarily. Or it may be needless since the rendering could have been more proper if the columns have been set dynamically.
The .NET GUI controls have Anchor property which can be used to stretch and adapt the ListView size to your device screen size. It is ok if your ListView has only one column. But what if there are 2 or more columns and column width ought to be allocated according to a pre-set ratio?
The code snippet below demonstrates how to dynamically set the columns width of a ListView at runtime. The logic is to allocate a percentage of the ListView control to each column. You can be sure that this logic, along with setting the Anchor property of the control to the right will always give your control a better rendering.
ListView1.Columns.Clear();
float fWidth ;
ColumnHeader colTo = new ColumnHeader();
colTo.Text = "Name";
fWidth = (0.38F * ListView1.Width);
colTo.Width = (int)fWidth;
ColumnHeader colMessage = new ColumnHeader();
colMessage.Text = "Number";
fWidth = (0.55F * ListView1.Width);
colMessage.Width = (int)fWidth;
//add the columns
ListView1.Columns.Add(colTo);
ListView1.Columns.Add(colMessage);
The two columns are allocated 38% and 55% respectively. The remaining 7% is an allowance for Vertical scrollbar so that Horizontal scrollbar will not appear automatically. I personally dislike having both bars on my ListView control.
Thursday, October 23, 2008
How to Sort a ListView object in Windows Mobile App
A WALK AROUND THE PROBLEM OF THE ABSENCE OF SORT PROPERTY IN WINDOWS MOBILE VERSION OF SYSTEM.WINDOWS.FORM.LISTVIEW
Recently, I was working on an application for Windows Mobile OS 5.0 device. I used a ListView control to display a group of names and associated numbers. I set the View property of the control to Details. But much to my chagrin, the records were not sorted. I scanned the ListView control for any property that may have to do with sorting. Of course, the ListView control has a sort property in windows form application. Interestingly, the property is absent in the windows mobile version of the .NET framework.
Thanks to resources on the internet, I was able to implement a sorting order for the listview. Here are the steps to follow to make a ListView control sort records in windows mobile application development. This trick can also be used in a windows form application.
STEP 1
I created a class that implements the IComparer interface. This class will be used to compare my objects and return the lesser or greater one
class contactsIComparer: IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
contacts contactX = (contacts)x;
contacts contactY = (contacts)y;
return contactX.getContactName.CompareTo(contactY.getContactName);
}
#endregion
}
STEP 2
Making each record to be displayed in my listView an object, I loaded all of them into an ArrayList collection. The essence of this approach is to enable comparison among the objects later using the Sort property of the ArrayList object.
ArrayList lst = new ArrayList();
For (int i=0; i < 10; i++){
lst.Add(new contacts(“Name” + i.ToString(),”Address”));
}
STEP 3
I use the Sort property of the ArrayList object to sort all its entries/records. As you can see below, I passed in, as an argument, the class that implemented the IComparer interface. The sort property uses the passed-in argument to sort the records.
lst.Sort(new contactsIComparer());
STEP 4
The last step here is to iterate through the ArrayList object (which is already sorted by now), get and add each entry to the ListView object as follows:
for (int t = 0; t < lst.Count; t++)
{
string text = lst[t].ToString();
string name = text.Substring(0, text.IndexOf(",")).Trim();
string number = text.Substring(text.IndexOf(",") + 1).Trim();
ListViewItem vItem = new ListViewItem(name);
vItem.SubItems.Add(number);
listView1.Items.Add(vItem););
}
As you can see above, I had to break up each string returned from my ArrayList object into two so that I can separate the Name from Number
Recently, I was working on an application for Windows Mobile OS 5.0 device. I used a ListView control to display a group of names and associated numbers. I set the View property of the control to Details. But much to my chagrin, the records were not sorted. I scanned the ListView control for any property that may have to do with sorting. Of course, the ListView control has a sort property in windows form application. Interestingly, the property is absent in the windows mobile version of the .NET framework.
Thanks to resources on the internet, I was able to implement a sorting order for the listview. Here are the steps to follow to make a ListView control sort records in windows mobile application development. This trick can also be used in a windows form application.
STEP 1
I created a class that implements the IComparer interface. This class will be used to compare my objects and return the lesser or greater one
class contactsIComparer: IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
contacts contactX = (contacts)x;
contacts contactY = (contacts)y;
return contactX.getContactName.CompareTo(contactY.getContactName);
}
#endregion
}
STEP 2
Making each record to be displayed in my listView an object, I loaded all of them into an ArrayList collection. The essence of this approach is to enable comparison among the objects later using the Sort property of the ArrayList object.
ArrayList lst = new ArrayList();
For (int i=0; i < 10; i++){
lst.Add(new contacts(“Name” + i.ToString(),”Address”));
}
STEP 3
I use the Sort property of the ArrayList object to sort all its entries/records. As you can see below, I passed in, as an argument, the class that implemented the IComparer interface. The sort property uses the passed-in argument to sort the records.
lst.Sort(new contactsIComparer());
STEP 4
The last step here is to iterate through the ArrayList object (which is already sorted by now), get and add each entry to the ListView object as follows:
for (int t = 0; t < lst.Count; t++)
{
string text = lst[t].ToString();
string name = text.Substring(0, text.IndexOf(",")).Trim();
string number = text.Substring(text.IndexOf(",") + 1).Trim();
ListViewItem vItem = new ListViewItem(name);
vItem.SubItems.Add(number);
listView1.Items.Add(vItem););
}
As you can see above, I had to break up each string returned from my ArrayList object into two so that I can separate the Name from Number
Friday, October 10, 2008
Take a peek at My Root

My name is Egbonwon Adesoji Olumide Johnson. Really, that was the name my parents gave me at birth but i have grown up and got used to being Egbonwon Adesoji Johnson (not much difference). My father's name is Egbonwon Nicodemus Orioye and my mother's name is Egbonwon Elizabeth Abiodun. I am the 2nd male child in a family of 3 male (Eda, myself and Tola) and 1 female (Cecelia).
Though not from a wealthy family, i had fond memories and partook in most of the fun and mischief that easily beset young boys.
Early in life, i have been made to believe i am special and most preferred in my extended family. It wasn't until i was about 22 years old that my younger brother voiced his observation. He said, "I've noticed that mother always gives you special attention and tends to be bias in dealing with you. It's just not fair". I humbly and truthfully told him then that i have observed the same thing and disliked it too.
But one thing i know about myself then and which i think must have endeared so much affection to me is that i was an easy going person. Easy going, calm, friendly, trustworthy and hardworking are the attributes i had and still do till now. In addition, i am very compassionate but could be firm in order to discourage unbecoming behaviour when relating with people.
From year 2000, i plunged into the ocean of software development and been swimming around since then, helping to develop different software solutions.
I will tell you more about me later in this blog.
Thanks for reading
Subscribe to:
Posts (Atom)