Skip to content

Commit 17a59f3

Browse files
Updated sample and readme file
1 parent 6fd49ee commit 17a59f3

15 files changed

+103
-475
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ public class ViewModel
7171

7272
![SQL DataBinding to WPF SfChart](https://user-images.githubusercontent.com/53489303/200743338-52fee1f9-d723-46b2-87ae-81da3b6e2067.png)
7373

74-
KB article - [How to bind the SQL Database to WPF Charts?](https://www.syncfusion.com/kb/11595/how-to-bind-the-sql-database-to-wpf-charts)
74+
## Troubleshooting
75+
76+
#### Path too long exception
77+
78+
If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to a shorter name before building the project.
79+
80+
For more details, refer to the KB on [How to bind the SQL Database to WPF Charts?](https://www.syncfusion.com/kb/11595/how-to-bind-the-sql-database-to-wpf-charts)

SQLWithChart/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

SQLWithChart/App.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
1+
using System.Configuration;
42
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
73
using System.Windows;
84

95
namespace SQLWithChart
@@ -14,4 +10,5 @@ namespace SQLWithChart
1410
public partial class App : Application
1511
{
1612
}
13+
1714
}

SQLWithChart/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

SQLWithChart/MainWindow.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF"
56
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
67
xmlns:local="clr-namespace:SQLWithChart"
7-
xmlns:chart="http://schemas.syncfusion.com/wpf"
88
mc:Ignorable="d"
99
Title="MainWindow" Height="450" Width="800">
10+
1011
<Grid>
1112

1213
<Grid.DataContext>
@@ -24,9 +25,10 @@
2425
</chart:SfChart.SecondaryAxis>
2526

2627
<chart:ScatterSeries ItemsSource="{Binding DataTable}"
27-
XBindingPath="xval"
28-
YBindingPath="yval"/>
28+
XBindingPath="xval"
29+
YBindingPath="yval"/>
2930
</chart:SfChart>
3031

3132
</Grid>
33+
3234
</Window>

SQLWithChart/MainWindow.xaml.cs

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Data;
4-
using System.Data.SqlClient;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
1+
using System.Text;
82
using System.Windows;
93
using System.Windows.Controls;
104
using System.Windows.Data;
@@ -27,40 +21,4 @@ public MainWindow()
2721
InitializeComponent();
2822
}
2923
}
30-
31-
public class ViewModel
32-
{
33-
public ViewModel()
34-
{
35-
try
36-
{
37-
SqlConnection thisConnection = new SqlConnection(ConnectionString);
38-
thisConnection.Open();
39-
string Get_Data = "SELECT * FROM ChartData";
40-
SqlCommand cmd = thisConnection.CreateCommand();
41-
cmd.CommandText = Get_Data;
42-
SqlDataAdapter sda = new SqlDataAdapter(cmd);
43-
DataSet ds = new DataSet();
44-
sda.Fill(ds);
45-
var table = ds.Tables[0];
46-
this.DataTable = table;
47-
}
48-
catch
49-
{
50-
MessageBox.Show("DataBase Error");
51-
}
52-
}
53-
54-
public object DataTable { get; set; }
55-
56-
public static string ConnectionString
57-
{
58-
get
59-
{
60-
string currentDir = System.Environment.CurrentDirectory;
61-
currentDir = currentDir.Substring(0, currentDir.Length - 10) + "\\LocalDataBase";
62-
return @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + currentDir + @"\SeriesItemsSource.mdf;Integrated Security=True";
63-
}
64-
}
65-
}
66-
}
24+
}

SQLWithChart/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

SQLWithChart/Properties/Resources.Designer.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

SQLWithChart/Properties/Resources.resx

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)