Posts

Donate

Match Network Path In A String Using Regular Expression

Hello, While working on a project, I was confronted with an issue on how to match or extract a network path. Normally, you can use string functions or built-in .NET code to check the validity of a path, but since I'm also refreshing my skills in Regular Expression. I prefer the latter as the solution. So the pattern to match the server path is presented below: ((\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\.*[a-zA-Z0-9-_ \\])(?="))) And to declare that pattern in your C# code, you have to escape the back slash characters. string ServerPath = "((\\\\\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\\\.*[a-zA-Z0-9-_ \\\\])(?=\")))" ; The input strings tested are as follows. Const ImagesPath As String = "\\ImagesServer\Logo Files\InetPub\TempProjects\" Const docsPath As String = "\\docsPathServer15\Health\Physicians\" Const vsPath As String = "\\vsServer909\vs2017\Projects" string manual = "\\manualServer\CompanyRules\EmployeeFiles\Cebu&

How To Update Multiple Rows In SQL Server Using One SQL Statement

Here's how to update multiple rows in one SQL statement using MSSQL. UPDATE tblEmp SET empSalary = empSrc.empSalary, empLevel = empSrc.empLevel FROM dbo.tblEmployees AS tblEmp INNER JOIN ( VALUES ( 001 , 10000 . 00 , 10 ), ( 002 , 32000 . 00 , 15 ), ( 003 , 9500 . 00 , 3 ) ) AS empSrc (empID, empSalary, empLevel) ON tblEmp.empID = empSrc.empID; Reference: How to update multiple columns of multiple rows in one SQL statement

MVVM RelayCommand And ViewModelBase Classes in VB.NET

Good evening! Here's a conversion of the RelayCommand and VewModelBase classes to VB.NET as reference for VB.NET programmers. RelayCommand Imports System.Windows.Input Public Class RelayCommand : Implements ICommand Private ReadOnly _execute As Action( Of Object ) Private ReadOnly _canExecute As Predicate( Of Object ) Public Sub New ( ByVal execute As Action( Of Object )) End Sub Public Sub New ( ByVal execute As Action( Of Object ), ByVal canExecute As Predicate( Of Object )) If execute Is Nothing Then Throw New ArgumentNullException( "execute" ) _execute = execute _canExecute = canExecute End Sub Public Function CanExecute ( ByVal parameter As Object ) As Boolean Implements ICommand.CanExecute Return (_canExecute Is Nothing ) OrElse _canExecute(parameter) End Function Public Custom Event CanExecuteChanged As EventHandler Implements ICommand

Refactor An MVVM ViewModel Class

Good afternoon! I recently asked the forums on how to refactor a ViewModel class given that in the future additional features or functionalities will be added, so the ViewModel class becomes bloated and hard to trace. All the commands, database operations and properties are declared in this class. So, the option I was thinking was segregation but I also need inputs from other experienced developers in the community. Sample ViewModel Class namespace MVVM.MainApplication.ViewModel { public class EmployeeViewModel : ViewModelBase { private ICommand _saveCommand; private ICommand _resetCommand; private ICommand _editCommand; private ICommand _deleteCommand; private Employee _employeeEntity; private EmployeeRepository _repository; private EmployeeModel _employeeModel; public EmployeeModel EmployeeModel { get { return _employeeModel; }

View Attendees Or Participants Of A Meeting In Outlook 365

Image
Hello! While familiarizing myself with Outlook 365, I had difficulty in viewing the attendees of a specific meeting. The layout of Outlook 365 has changed and I didn't see the Tracking button under Meeting Occurrence tab. After doing some research, the solution to show the attendees is to check the Normal option of People Pane under View tab.

WPF CRUD With DataGrid, Entity Framework And VB.NET

Image
Good morning! Here's the VB.NET version of this post WPF CRUD with DataGrid and Entity Framework C# . The steps to accomplish basing from the C# post are: a. Run the create table script assuming that you haven't created the Students table. b. Create a VB.NET WPF project. c. Replace the XAML markup of the window control. Once done, the scripts for the repository class and window code-behind are as follows: Repository Class Public Class StudentRepository Private studentContext As StudentEntities = Nothing Public Sub New () studentContext = New StudentEntities() End Sub Public Function GetStudent ( ByVal id As Integer ) As Student Return studentContext.Students.Find(id) End Function Public Function GetAll () As List( Of Student) Return studentContext.Students.ToList() End Function Public Sub AddStudent ( ByVal student As Student) If student IsNot Nothing Then

WPF CRUD With DataGrid, Entity Framework And C#.NET

Image
Good evening! Here's a simple WPF CRUD(Create/Update/Delete) application using DataGrid and Entity Framework. This doesn't involve the MVVM pattern and input validation. Maybe if I have time, in the future I'll post an MVVM equivalent post ( Update: I already have additional examples using RepoDB ORM and MVVM pattern in both C# and VB.NET at the end of this article ). So to proceed, execute the SQL script below and make sure to replace the database name with an existing one. USE [your_database] GO /****** Object: Table [dbo].[Students] Script Date: 3/31/2018 11:24:23 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Students]( [ID] [ int ] IDENTITY ( 1 , 1 ) NOT NULL , [Name] [ varchar ]( 50 ) NULL , [Age] [ int ] NULL , [Address] [ varchar ]( 50 ) NULL , [Contact] [ varchar ]( 50 ) NULL , CONSTRAINT [PK_Students] PRIMARY KEY CLUSTERED ( [ID] ASC ) WITH (PAD_INDEX = OFF , STATISTICS_N

Bootstrap DatePicker Arrow Appears At The Bottom of Calendar

Image
Hi, I was asked by a developer on how to fix the arrow which appears at the bottom of the calendar dropdown and not below the textbox. This issue was raised in my previous post Bootstrap DatePicker Control in ASP.NET Webforms . The solution is to reference the bootstrap-datepicker.css instead of bootstrap-datepicker3.standalone.css <link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/css/bootstrap-datepicker.css" /> <script type= "text/javascript" src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script> <script type= "text/javascript" src= "Scripts/bootstrap.min.js" ></script> <script type= "text/javascript" src= "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/js/bootstrap-datepicker.min.js" ></script> <script type= "text/javascript" > Output

Alternative To Union In T-SQL

Good morning! In the event that you need to replace your queries using Union such as below: Use DBJersonsHW go SELECT DISTINCT [EmpName] AS [EmployeeName], EmpAddress As [Address] FROM tblEmployeesMain UNION SELECT DISTINCT [EmpName] AS [EmployeeName], EmpAddress As [Address] FROM tblEmployeesMetro ORDER BY [EmpName]; The alternative for that is to use Full Outer Join as presented below: Use DBJersonsHW go SELECT Distinct Coalesce(tblEmployeesMain.EmpName, tblEmployeesMetro.EmpName) AS EmployeeName, Coalesce(tblEmployeesMain.EmpAddress, tblEmployeesMetro.Address) AS Address, FROM tblEmployeesMain FULL Outer JOIN tblEmployeesMetro on tblEmployeesMain.EmpName = tblEmployeesMetro.EmpName order by EmpName Cheers! :-)

How To Read XML File Using DataTable.ReadXml() In C#

Image
Good afternoon friends! In this tutorial, I will demonstrate how to read an XML file using DataTable's ReadXml() method. While reading a file using DataSet's ReadXml() method is straightforward, using the DataTable's method might cause run-time or logical bugs. One example is that when using the DataTable's ReadXml() function, the DataTable object does not contain any records or nothing at all given that fact that the method has successfully executed. To proceed, we will read an XML file below called books.xml taken from MSDN page using DataTable's ReadXml() method. <?xml version="1.0" encoding="utf-8" ?> <catalog> <book id= "bk101" > <author> Gambardella, Matthew </author> <title> XML Developer's Guide </title> <genre> Computer </genre> <price> 44.95 </price> <publish_date> 2000-10-01 </publish_date> <description&g

Donate