The regular split function specifies a char array as the splitter... Here's a simple bit of code to use a string as the splitter...
string[] result = pageText.Split(new string[] { "|~|" }, StringSplitOptions.None);
The regular split function specifies a char array as the splitter... Here's a simple bit of code to use a string as the splitter...
string[] result = pageText.Split(new string[] { "|~|" }, StringSplitOptions.None);
Posted at 04:48 PM | Permalink | Comments (0)
Custom exceptions are great. They allow pinpointing the location your application is falling over. Furthermore, with the InnerExceptions, you can add a meaningful note to assist in rectifying the issue.
Here's an example... a custom exception named ExceptionPdfImport.
[Serializable]
public class ExceptionPdfImport : Exception
{
public string ErrorMessage
{
get
{
return base.Message.ToString();
}
}
public ExceptionPdfImport(string errorMessage)
: base("Error importing PDF", new Exception(errorMessage)) {}
}
Now, any time in code we can throw an exception of type ExceptionPdfImport...
throw new ExceptionPdfImport("File not found");
Which we can view from the debugger as such:-
Posted at 01:44 PM | Permalink | Comments (0)
After trying different printers, printing from within Visual Studio, xps printer drivers, looking through the options... I couldn't figure out how to get SQL Server 2005 to print a database diagram correctly.
Instead, I kept getting my tables looking something like this:-
A (not really great) work-around it is to select all then click Edit > Copy Diagram to Clipboard... then paste it into Word.
Posted at 02:05 PM | Permalink | Comments (0)
After using the SSIS Import and Export Wizard, I had spent a long time manipulating data for an import package. When finally complete, I realise I'm appending the data, as I forgot to tick the Delete rows in destination table box on the wizard... d'oh!
After a bit of poking around I found that what I needed to do was in the Control Flow of the package, add an Execute SQL Task item.
After this, you'll need to set the properties for Connection, then on the SqlStatementSource add your TRUNCATE, such as:-
TRUNCATE TABLE [Intranet].[dbo].[Intranet_MyHR_TimeStatements]
GO
As you only have a single line to type in the properties window, it might be worth copying the above or using notepad to be able to paste the new line characters.
Posted at 10:12 AM | Permalink | Comments (0)
So you've added a grouping to your report, and selected that after each Group Footer you want a new page by the Section Expert...
But when viewing your report, there will be a blank page at the end. No problem! Just click the "X+2" button besides "New Page After", and enter the following in the formula area:-
And hey presto, that empty last page will be a thing of the past!
Posted at 11:34 AM | Permalink | Comments (0)
The standard programmatic way of having Crystal Reports connect to a database in C# would be along the lines of:-
repDoc.SetDatabaseLogon( "Username", "Password", "Server_DSN", "DB_Name", false);
But in your web.config you may have a connection string already defined... for example:-
<connectionStrings>
<!-- the machine.config references this, so re-map it to the correct SQL DB -->
<remove name="LocalSqlServer"/>
<add name="SqlServer"
connectionString="Data Source=server\instance;Initial Catalog=dbname;user id=username;password=password"/>
</connectionStrings>
The following code allows you to set a data source for your report, using the web.config connection string:-
// Need a reference to the System.Configuration Namespace
string connectionString =ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString;
SqlConnectionStringBuilder SConn =
new SqlConnectionStringBuilder(connectionString);
repDoc.DataSourceConnections[0].SetConnection(
SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
Posted at 11:07 AM | Permalink | Comments (0)
So, you have a report which groups by week... but by default Crystal Reports has weeks beginning on Sunday. What if you want the week to start on Monday? There's no option to do this, you have to use a custom formula.
Fortunately, a good chap named Ken Hamady has detailed the formula required at this link:-
http://kenhamady.com/cru/archives/277
In case the page vanishes, as sites do over the years, his formula is as follows:-
DateTimeVar YourDate := {Orders.Order Date};
Numbervar WeekStart :=4;
Date (YourDate) - DayOfWeek (YourDate) + WeekStart
- (if DayOfWeek (YourDate) < WeekStart then 7)
Where the first line contains your date field. The number 4 gets replaced with the day to start with (1=Sunday, 7=Saturday). Also, when grouping on the formula, use the "for each DAY" option as we are now in control the grouping.
To add the formula, perform the following steps...
Posted at 11:56 AM | Permalink | Comments (0)
Want a tutorial on VSTS Database Edition and incremental database deployments? Give this video a shot...
Posted at 11:35 AM | Permalink | Comments (1)
These are two good articles on how to do this...
The second is by far easiest to follow. To repeat the instructions...
Posted at 09:27 AM | Permalink | Comments (0)
It's nice to see if your systems are online and working happily.
The ServersCheck application, available from here (free 21 day trial) or an older version here (no expiry, but 10 monitor limit).
The system can do all sorts of notifications, based on a trigger for an event. Events can be Pings, HTTP Status Codes, Oracle connections, and loads more. Notifications can be E-mails, text messages, MSN Messenger alerts and more.
You can even purchase temperature and humidity sensors to a free network port.
It also provides reports (even having exclusion times for scheduled / contracted maintenance periods), which are great for proving your SLA's are being met.
Posted at 01:44 PM | Permalink | Comments (0)