Community of VE/MapPoint Users and Developers
This is a discussion on Probleme with access 2003 and MapPoint 2006 within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hi, I devellop an application in C# to use mapPoint and Access query. So in first time, i created a ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Probleme with access 2003 and MapPoint 2006 I devellop an application in C# to use mapPoint and Access query. So in first time, i created a code which create a data base. My code works, this is very very very slow. BUT it works. In second time i created an other application to make query on my data base and i display results on a datagridview. And again my code works. And now, i add a mapPoint control. Just the control and i load a map. So i make a query on my data base it works, i load the MapPoint control, it works too, i make an other query on my data base, the application crash. this my code : Code: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.OleDb;using System.IO;namespace Recherche_BDD_1{publicpartialclassForm1 : Form{public Form1(){InitializeComponent();}//MapPoint.Symbols all;String objTemplate = "C:/Program Files/Microsoft MapPoint Europe/Templates/Nouvelle carte d'Europe.ptt";MapPoint.Map objMap = null;privatevoid Form1_Load(object sender, EventArgs e){}privatevoid button1_Click(object sender, EventArgs e){MapPoint.Map objMap = null;string connString = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=Contacts.mdb";if (File.Exists("Contacts.mdb") == true){OleDbConnection conn = newOleDbConnection(connString);conn.Open();string query = "SELECT * FROM Contacts Where Rue = 'Avenue Du 14 Juillet'";OleDbDataAdapter adapter = newOleDbDataAdapter(query, conn);DataSet datas = newDataSet();adapter.Fill(datas);conn.Close();adapter = null;conn = null;dataGridView1.DataSource = datas.Tables[0];datas = null;}else{MessageBox.Show("Erreur le fichier n'existe pas");}}privatevoid dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e){}privatevoid button_Erase_Data_Click(object sender, EventArgs e){axMappointControl1.NewMap(objTemplate);objMap = axMappointControl1.ActiveMap;objMap.MapStyle = MapPoint.GeoMapStyle.geoMapStyleData;}}} Like you can see, this is very simple. just a query, and load a map. I use the following programs : Access 2003, Visual studios 2005, windows XP pro SP2 version 2002, The debbuger give me the following error code : Le moteur de base de données Microsoft Jet ne peut pas trouver la table ou la requête source 'Contacts'. Assurez-vous qu'elle existe et qu'elle est correctement orthographiée. => translation : The data base controle of Microsoft Jet cannot find the data base or the source query 'Contacts'. Look if it exist and it is correctly misspelled. Error code : -2147217865, I search on the web where can come from the problem. And i fund just an answer which can join my problem. VS 2005 & Access DB problem - MSDN Forums I installed a patch, change some options. But i have always the same problem. If you have an example of code which can be better. Or if there is an error in my code. Please inform me I Thank you. |
| |||
|
Hi, I didn't found where was my problem. But, i changed my code, and it works now. ![]() I have an other question now, the latest. There is one week, what i try to find how to use MapPoint 2006 and Access 2003 always in C#. I have read the examples of Mappoint on the datasheet. But that dont works, moreover, there is any example on the web. And Even on your forum, when someone try to know how works access and mappoint there isn't any answer .I give you a part of my code : Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
namespace Test_Map_point_access
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
#region variable pour la connection a la base de donnée
String objTemplate = "C:/Program Files/Microsoft MapPoint Europe/Templates/Nouvelle carte d'Europe.ptt";
MapPoint.Map objMap = null;
MapPoint.Symbols all;
//déclaration de la connection
privateOleDbConnection Conn = newOleDbConnection();
//déclaration du chemin de l'éxécutable
privatestring BDDPath = Application.ExecutablePath;
//déclaration du chemin de la connection de la base de donnée
privatestring ConnString;
#endregion
#region variables Connection pour ComboClass et listclass
//déclaration du dataset
privateDataSet DtsClass = newDataSet();
//déclaration de la datatable
privateDataTable DttClass = newDataTable();
//déclaration de la requete sql pour le comboclass
privatestring SqlClass = "SELECT * FROM Contacts";
#endregion
#region variables connection pour la datagrid et recherche
//déclaration du dataset
privateDataSet DtsGrid = newDataSet();
//déclaration du datatable
privateDataTable DttGrid = newDataTable();
//déclaration de la requete sql
privatestring SqlGrid = "SELECT * FROM Contacts";
//déclaration de la requete sql
privatestring SqlSearch;
//déclaration du commande builder
privateOleDbCommandBuilder CmdGrid = newOleDbCommandBuilder();
//déclaration du datarow
privateDataRow DtrGrid;
#endregion
#region variables
//Import de la class Variable
ClassVariables CsV = newClassVariables();
#endregion
privatevoid Form1_Load(object sender, EventArgs e)
{
#region Construction de la connection
axMappointControl1.NewMap(objTemplate);
objMap = axMappointControl1.ActiveMap;
objMap.MapStyle = MapPoint.GeoMapStyle.geoMapStyleData;
//Arangement du chemin de la prise de la base de donnée
this.BDDPath = this.BDDPath.Substring(0, this.BDDPath.LastIndexOf("\\"));
//on crée le chemin de la connection a la base de donnée
this.ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + this.BDDPath + "\\Contacts.mdb";
//on crée la connection a la base de donnée
this.Conn.ConnectionString = this.ConnString;
#endregion
#region datagridview
//déclaration du data adapteur pour le datagridview
OleDbDataAdapter DtaGrid = newOleDbDataAdapter(this.SqlGrid, this.Conn);
//on leve l'exception
try
{
DtaGrid.Fill(this.DtsGrid, "Contacts");
}
catch (Exception ex)
{
//affichage de l'érreur
MessageBox.Show("Une Erreur est survenue, si cela persiste veuillez contacter au plus vite le programmeur");
//on ferme la connection
this.Conn.Close();
//on quitte l'application
Application.Exit();
}
//on rempli la liste avec le dataset
this.DttGrid = this.DtsGrid.Tables["Contacts"];
//on affiche la liste dans le datagridview
this.Dtg.DataSource = this.DttGrid;
//on stylise la datagridview
this.StyleDtg();
#endregion
//rafraichissement de la fenetre
this.Show();
//on ferme la connection
this.Conn.Close();
}
#region Fonctions
privatevoid StyleDtg()
{
this.Dtg.ColumnHeadersDefaultCellStyle.Font = newFont("Tahoma", 9, FontStyle.Bold, GraphicsUnit.Point);
this.Dtg.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.ControlDark;
this.Dtg.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
this.Dtg.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
this.Dtg.DefaultCellStyle.Font = newFont("Tahoma", 8, FontStyle.Regular, GraphicsUnit.Point);
this.Dtg.DefaultCellStyle.BackColor = Color.Empty;
this.Dtg.AlternatingRowsDefaultCellStyle.BackColor = SystemColors.ControlLight;
this.Dtg.CellBorderStyle = DataGridViewCellBorderStyle.Single;
this.Dtg.GridColor = SystemColors.ControlDarkDark;
Dtg.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
#endregion
privatevoid button_Afficher_rue_Click(object sender, EventArgs e)
{
//on vide le dataset
this.DtsGrid.Clear ();
MapPoint.Field objField;
MapPoint.DataSets objDSS = axMappointControl1.ActiveMap.DataSets;
axMappointControl1.ActiveMap.MapStyle = MapPoint.GeoMapStyle.geoMapStyleTerrain;
//Base de données Access avec une table
//*******************************************
// zone de test de l'api mappoint avec access
//*******************************************
string szconn = "//Contacts.mdb";// The path must be change :D
object missing = System.Reflection.Missing.Value;
if (File.Exists("//Contacts.mdb") == true) // The path must be change too
{
Console.WriteLine("Le fichier existe !");
object[] myranges = newobject[9] { 0, 4, 8, 12, 16, 20, 35, 50, 100 };
all = objMap.Symbols;
MapPoint.DataSet oDS = objDSS.ImportData(szconn, missing,
MapPoint.GeoCountry.geoCountryFrance,
MapPoint.GeoDelimiter.geoDelimiterTab,0); //Define data map columns
object LatitudeIndex = 3;
object LongitudeIndex = 2;
object MoyenneIndex = 8;
//Now get fields
object[] datafields = newobject[3];
datafields[0] = oDS.Fields.get_Item(ref LongitudeIndex);
datafields[1] = oDS.Fields.get_Item(ref LatitudeIndex);
datafields[2] = oDS.Fields.get_Item(ref MoyenneIndex);
//affichage avec définition de l'échelle (couleur et intervalle)
MapPoint.DataMap datamap = oDS.DisplayDataMap(MapPoint.GeoDataMapType.geoDataMapTypeShadedCircle,
datafields, MapPoint.GeoShowDataBy.geoShowByLatLong,
MapPoint.GeoCombineDataBy.geoCombineByDefault,
MapPoint.GeoDataRangeType.geoRangeTypeDiscreteEqualRanges,
MapPoint.GeoDataRangeOrder.geoRangeOrderLowToHigh,
12, 8, myranges, missing, missing, missing, missing);
}
else
{
Console.WriteLine("Le fichier n'éxiste pas !");
}
//on vérifi qu'il y a quelque chose dans la txtsearch
this.SqlSearch = "SELECT * FROM Contacts Where Rue = 'Avenue Du 14 Juillet'";
//on ouvre la connection
this.Conn.Open ();
//déclaration du data adapter
OleDbDataAdapter Dta = newOleDbDataAdapter ( this.SqlSearch , this.Conn );
//on leve l'exception
try
{
//on rempli le dataset avec la table
Dta.Fill ( this.DtsGrid , "Contacts" );
}
catch ( Exception ex )
{
//affichage de l'érreur
MessageBox.Show ( "Une Erreur est survenue, si cela persiste veuillez contacter au plus vite le programmeur" );
//on ferme la connection
this.Conn.Close ();
//on ferme la fenetre
this.Close ();
//on quitte l'application
Application.Exit ();
}
//on rempli la liste du datagridview avec le dataset
this.DttGrid = this.DtsGrid.Tables [ "Contacts" ];
//on affiche la liste du datagridview dans le datagridview
this.Dtg.DataSource = this.DttGrid;
//on stylise la datagridview
this.StyleDtg ();
//rafraichissement de la fenetre
this.Show ();
//on ferme la connection
this.Conn.Close ();
}
}
}
Actually, i dont know how put the datas in the good fields (sorry for my english). When i create : object LatitudeIndex = 3; object LongitudeIndex = 2; etc ... and data field... because i have an error :s. If you will have a very simple example. Because your example in the datasheet isn't very explicit :s. And even on the msd there is always the same part of code ... (paye ton travail en deux deux). And never a very good example to use an access 2003 data base and mappoint 2006. I thank you very much. And all my apologies for all of these questions. ![]() regards, |
| |||
| Re: Probleme with access 2003 and MapPoint 2006
Hi, Can you tell us what the error is and the offending code line?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Probleme with access 2003 and MapPoint 2006
Hi, The error is at the end of code, when i use : //affichage avec définition de l'échelle (couleur et intervalle) MapPoint.DataMap datamap = oDS.DisplayDataMap(MapPoint.GeoDataMapType.geoDataMapTypeShadedCircle, datafields, MapPoint.GeoShowDataBy.geoShowByLatLong, MapPoint.GeoCombineDataBy.geoCombineByDefault, MapPoint.GeoDataRangeType.geoRangeTypeDiscreteEqualRanges, MapPoint.GeoDataRangeOrder.geoRangeOrderLowToHigh, 12, 8, myranges, missing, missing, missing, missing); I have the following error : {"Paramètre incorrect.\r\n"} => Wrong parameters ![]() I'm sure what i forget something, and as i said, i dont know how use datamap. I watched the datasheet for avoid syntax error. But even with that i dont know how use access with MapPoint. Moreover, my data base is like this example : data data "Longitude" "Latitude" data data data data "Average<=>(Moyenne)" data data data Thank you for your answer. regards; |
| ||||
| Re: Probleme with access 2003 and MapPoint 2006
It's not an Access problem.. it's DisplayDataMap. It will kick out that error if *any* of the parameters are incorrect or don't match what it expects.. My stock answer is to read the sections in "Programming MapPoint in .NET" as I always go back and refer to it when I am working with DisplayDataMap myself... I keep thinking I should create a guide or article on DisplayDataMap on MP2Kmag.com but I haven't gotten around to it. Eric
__________________ Order MapPoint 2006 | Read Programming MapPoint in .NET | Start Using the Pushpin Tool - Free Trial Download - click here. |
| |||
| Re: Probleme with access 2003 and MapPoint 2006
Hi, Since all (or most of the) arguments to this method are optional you can find out which one is the offending one if you start with only a few arguments and increase one by one.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Probleme with access 2003 and MapPoint 2006
Hi, I thank you, for your answers. I didn t found where is the wrong parameter, but i used an other data source, with text file . I make a request, i write the results in a text file. And i use this file as data source. My code works I will search for access data base, moreover i had already watched fiew pages of "Programming MapPoint in .NET" Eric. On this site : Programming MapPoint in .NET - Google Recherche de Livres There is few page of this book. So perhaps, if i sell one of my kidney one day. I will buy this book .Thank you for your answers again. |
![]() |
| ||||
| Posted By | For | Type | Date | |
| MapPoint Download - MP2K Magazine | This thread | Refback | 05-06-2008 03:20 PM | |
| Latitude / Longitude DMS -> Decimal Converter - MP2K Magazine | This thread | Refback | 05-05-2008 11:56 PM | |
| MapPoint Articles - MP2K Magazine | This thread | Refback | 05-05-2008 10:34 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 04-30-2008 05:45 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Upgrading from 2003 to 2006 | BobFromBoston | MapPoint 2006/2009 Discussion | 4 | 01-28-2007 09:47 AM |
| Difference between MapPoint 2006 and MapPoint 2006 Fleet | jlewis | MapPoint 2006/2009 Discussion | 1 | 11-21-2006 08:18 AM |
| using access 2003 queries as a data source | roberta walker | MapPoint 2006/2009 Discussion | 2 | 04-27-2004 07:06 AM |
| mappoint 2002 and 2004 with access 2003 based datalink | Claus | MapPoint 2006/2009 Discussion | 0 | 03-20-2004 03:33 AM |
| when will MapPoint 2003 be available | Anonymous | MapPoint 2006/2009 Discussion | 4 | 09-10-2002 10:56 PM |
Cheap Flights to Brussels
Book cheap flights to Brussels online today. Brussels is a city with diverse culture with over 100 museums to visit and an array of different architectural designs to view.
Spain Weather
Check Spain Weather before you travel. We provide information on Spain including weather, flights and accommodation.
Cheap Holiday Turkey
Booking a cheap holiday to Turkey doesn't have to be at the expense of enjoyment. Dealchecker.co.uk searches holidays from the leading UK Tour Operators.
Egypt Holidays
Visit one of the most spectacular sightseeing destinations in the world with The Holiday Place. Egypt holidays provide a fantastic break!
Cheap Turkey Holidays
The best time of year to sneak in cheap Turkey holidays is during the off-peak season. Check out the great deals available during April, May or October. For other tips on how to bag a great value holiday simply check online at ulookubook.com
Cheap Travel
Travel.co.uk has some excellent offers on cheap travel. Click here.
Cheap Holidays to Goa
Dine on delightful seafood in west India. Find information on cheap holidays in Goa at On The Beach.