Category / Section
How to display Maps from the SQL data base
1 min read
You can display WinForms Maps using data from SQL database by establishing the connection to it. Add the required database (.mdb) file from which the data that needs to be accessed into the project.
Establish the OleDbConnection and access the data as demonstrated in the following code sample.
private void AddData() { //Sets database connection. string connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", @"DataBase_File.mdb"); OleDbConnection Connection = new OleDbConnection(connectionString); Connection.Open(); OleDbCommand command = new OleDbCommand("Select Top 10 * from [Data]", Connection); OleDbDataAdapter DataAdapter = new OleDbDataAdapter(command); DataAdapter.Fill(dataset, "Data"); //Sets DataTable to the Data property. this.Data = dataset.Tables["Data"]; // Data.DefaultView Connection.Close(); }
The accessed data can be used in maps as demonstrated in the following code sample.
shapeLayer.ItemSource = viewmodel.Data; |
Sample for accessing data from SQL data base: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CS1454297907