XML support is integrated into all the components in SQL Server.
Search This Blog
Thursday, October 29, 2015
Tuesday, October 27, 2015
Saturday, October 17, 2015
'cmake' is not recognized as an internal or external command error
'cmake' is not recognized as an internal or external command
Solution:
Add the path to system variables Path
Solution:
Add the path to system variables Path
Etichete:
cmake
Thursday, October 15, 2015
Visual Studio show Decrease Increase Line Indent Buttons
Visual Studio > Decrease/Increase Line Indent buttons
Go o the toolbar and press:
Go o the toolbar and press:
than check Decrease/Increase Line Indent:
Etichete:
Visual Studio
Wednesday, October 7, 2015
Find max value of a column in a DataTable c#
C# > System.Data > DataTable > Max Value
Find max value of a column in a DataTable C#.
var maxValue = DataTable1.AsEnumerable().Max(r => r.Field<double>("value"));
Find max value of a column in a DataTable C#.
var maxValue = DataTable1.AsEnumerable().Max(r => r.Field<double>("value"));
Etichete:
c#
Thursday, October 1, 2015
Telerik report bind to DataTable and add a sample calculated field
Telerik > Reporting > Bind to DataTable
Example
Bind to DataTable and add a sample calculated field.
Example
Bind to DataTable and add a sample calculated field.
string connString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=HR;Integrated Security=True";
string cmdText = "SELECT FirstName, LastName FROM Person;";
SqlDataAdapter da = new SqlDataAdapter(cmdText, connString);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
Telerik.Reporting.ObjectDataSource ods = new Telerik.Reporting.ObjectDataSource();
ods.DataSource = dt;
ods.CalculatedFields.Add(new Telerik.Reporting.CalculatedField("FullName", typeof(string), "=Fields.FirstName + ' ' + Fields. LastName "));
Telerik.Reporting.Report rpt = new Telerik.Reporting.Report();
rpt.DataSource = objectDataSource;
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
reportSource.ReportDocument = rpt;
reportViewer1.ReportSource = reportSource;
reportViewer1.RefreshReport();
Etichete:
Telerik
Monday, September 28, 2015
Choose Visual Basic Example
VB.NET > Functions > Choose
Returns a member of the list passed in Choice().
It is based on the value of Index. The first member of the list is selected when Index is 1.
Example
Dim choice = Choose(2, "val1", "val2", "val2") // "val2"
Returns a member of the list passed in Choice().
It is based on the value of Index. The first member of the list is selected when Index is 1.
Example
Dim choice = Choose(2, "val1", "val2", "val2") // "val2"
Etichete:
VB.NET
Thursday, September 24, 2015
Appends text to a file C#
C# > Files > File Class > AppendText
Appends text to an existing file or create a new file if the specified file does not exist.
Example
using(System.IO.StreamWriter sw = System.IO.File.AppendText(@"c:\log.txt"))
{sw.WriteLine("logline");
}
Etichete:
c#
Tuesday, September 15, 2015
Convert to double TimeSpan C#
C# > System > TimeSpan Structure
TimeSpan represents a time structure.
Examples
1. Convert to double
TimeSpan represents a time structure.
Examples
1. Convert to double
TimeSpan ts = TimeSpan.FromMinutes(12.45);
double time = ts.TotalMinutes;
Etichete:
c#
Friday, August 14, 2015
SOUNDEX SQL Server Example
SQL Server > Built-in Functions > SOUNDEX
SOUNDEX converts an alphanumeric string to a four-character code that is based on how the string sounds when spoken.
Example
SOUNDEX converts an alphanumeric string to a four-character code that is based on how the string sounds when spoken.
Example
SELECT SOUNDEX ('Jan'), SOUNDEX ('Jane');
Result:
(No column name) (No column name)
J500 J500
Etichete:
SQL Server
TRY_CAST SQL Server Example
SQL Server > Built-in Functions > TRY_CAST
Try to cast a value to the specified data type.
If the cast not succeeds returns null.
Example
Cast succeeded
Try to cast a value to the specified data type.
If the cast not succeeds returns null.
Example
SELECT
CASE WHEN TRY_CAST('1' AS float) IS NULL
THEN 'Cast failed'
ELSE 'Cast succeeded'
END AS Result;
Result
SELECT
CASE WHEN TRY_CAST('xx' AS float) IS NULL
THEN 'Cast failed'
ELSE 'Cast succeeded'
END AS Result;
Result
Cast failed
Etichete:
SQL Server
Monday, August 10, 2015
Pow C# Example
C# > System > Math class > Pow
Pow number raise a number to the specified power.
Example:
double pow = Math.Pow(2, 8); // 256
Pow number raise a number to the specified power.
Example:
double pow = Math.Pow(2, 8); // 256
Etichete:
c#
Tuesday, August 4, 2015
Scroll to selected index DataGridView
C# > DataGridView > FirstDisplayedScrollingRowIndex
Setting this property raises scroll event to match selected index.
Example
Setting this property raises scroll event to match selected index.
Example
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows.Count - 1;
Etichete:
c#
Friday, July 31, 2015
Read fast text file line by line C#
C# > Files > File Class > OpenText
Open text file for reading line by line.
Example
Read fast text file line by line C#
Read fast text file line by line C#
using (StreamReader sr = File.OpenText(@"c:\filename.txt"))
{
while (!sr.EndOfStream)
{
sr.ReadLine();
}
}
}
Etichete:
c#
Monday, July 27, 2015
INSERT SQL Server Example
SQL Server > DML > INSERT
INSERT adds one or more rows to a table or a view.
Example
INSERT adds one or more rows to a table or a view.
- When insert data into a view, the view must reference exactly one base table in the FROM clause of the view.
- When insert into a multi-table view you must use a column list that references only columns from one base table.
Example
INSERT INTO Sales (ProductName, Price, [Date]) VALUES ('Product1', 200, GETDATE());
Etichete:
SQL Server
Friday, July 24, 2015
How to bind to a parent DataContext WPF
WPF > RelativeSource
IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.IsAPGCSourceFitted}"
Monday, July 20, 2015
Day VB.Net Example
VB.NET > Functions > Day
Day returns the day of the month as an integer between 1 and 31.
Example
Dim today As Integer = Microsoft.VisualBasic.DateAndTime.Day(Now)
Day returns the day of the month as an integer between 1 and 31.
Example
Dim today As Integer = Microsoft.VisualBasic.DateAndTime.Day(Now)
Etichete:
VB.NET
Wednesday, June 24, 2015
C# Regex to match the words with dot
C# > Text > Regular Expressions > Split with dot
string[] substrings = Regex.Split("test.regex.dot", @"\.");
string[] substrings = Regex.Split("test.regex.dot", @"\.");
Thursday, June 18, 2015
Remove border Telerik RadGridView
Telerik > RadGridView > Remove border
radGridView1.GridViewElement.DrawBorder = false;
radGridView1.GridViewElement.GroupPanelElement.DrawBorder = false;
Etichete:
Telerik
Monday, June 15, 2015
KeyNotFoundException Collection C# Example
Collections > Generic > KeyNotFoundException
This is thrown when try to retrieve an element from a collection using a key that does not exist in that collection.Example
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("key1","value1");
try
{
string val = dict["key2"];
}
catch (KeyNotFoundException)
{
throw new KeyNotFoundException("KeyNotFoundException!");
}
Wednesday, May 20, 2015
Print PictureBox Image C# Example Using PrintDocument
C# > Print > PrintDocument
PrintDocument sends out to the printer.
Example
Print image
using System;
PrintDocument sends out to the printer.
Print image
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBox1.Image, 100, 100, 700, 600);
}
}
}
}
}
}
Etichete:
c#
Tuesday, May 19, 2015
Monday, May 18, 2015
Subtract SQL Server example
SQL Server > Operators > Subtract
- Operator (minus) subtracts two numbers or a number (in days) from date.
Example
1. Subtracts values from 2 numeric columns
create table #test(value int, fee int)
insert into #test(value, fee) values (500,50),(100,10)
select
value - fee as 'diff'
from
#test
drop table #test
Result
diff
450
90
2. Subtracts from date
SELECT getdate() - 1 AS 'Subtract Date';
- Operator (minus) subtracts two numbers or a number (in days) from date.
Example
1. Subtracts values from 2 numeric columns
create table #test(value int, fee int)
insert into #test(value, fee) values (500,50),(100,10)
select
value - fee as 'diff'
from
#test
drop table #test
Result
diff
450
90
2. Subtracts from date
SELECT getdate() - 1 AS 'Subtract Date';
Etichete:
SQL Server
C# unit test using Moq verify property has been set
C# > Unit test > Moq > Verify property has been set
SetupSet : Specifies a setup on the mocked type for a call to a property setter.
VerifySet : Verifies that a property has been set on the mock, regardless of its value.
Example
using System;
namespace UnitTestProject1
{
public interface Interface1
{
int Id { get; set; }
}
}
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var mocker = new Mock<Interface1>();
mocker.SetupSet(x => x.Id = 1);
mocker.Object.Id = 1;
mocker.VerifySet(x => x.Id);
}
}
}
Etichete:
c#,
Unit tests
Friday, May 15, 2015
Convert string to date C# example
C# > System Namespace > DateTime > Parse
Parse converts string to a date.
Example
Parse converts string to a date.
Example
string value = "5/15/2015";
var dte = DateTime.Parse(value,
CultureInfo.InvariantCulture); // {5/15/2015 12:00:00 AM}
Etichete:
c#
Thursday, May 14, 2015
Find last row Telerik RadGridView
Telerik > RadGridView > Find last row
GridViewRowInfo lastRow = radGridView.Rows[radGridView.Rows.Count - 1]; lastRow.IsSelected = true;
Wednesday, May 13, 2015
C# Generic Interface Example
C# > Generics > Generic Interface
Example
Example
class Serializer1 { public string Name { get; set; } };
class Serializer2 { public string Name { get; set; } };
interface GenericSerializer <T>
{
string Name(T tValue);
}
class Serializer<T>: GenericSerializer<T>
{
public string Name(T tValue)
{
var prop = tValue.GetType().GetProperty("Name");
return prop.GetValue(tValue, null) as string;
}
}
Serializer1 s1 = new Serializer1() { Name = "Serializer1" };
Serializer2 s2 = new Serializer2() { Name = "Serializer2" };
Serializer<Serializer1> serializer1 = new Serializer<Serializer1>();
string name1 = serializer1.Name(s1);
Serializer<Serializer2> serializer2 = new Serializer<Serializer2>();
string name2 = serializer2.Name(s2);
Subscribe to:
Posts (Atom)