Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vfp CustomDataClass flips syntax error at runtime
Message
From
05/03/2005 11:18:07
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Vfp CustomDataClass flips syntax error at runtime
Miscellaneous
Thread ID:
00993018
Message ID:
00993018
Views:
58
Hi Mere Mortals,

One of my backends in an MM.NET application is a small vfp database that contains 6 small data tables.
I have to write cutom data classes for my bizobjs because the VS data wizards treat vfp databases as second class citizens.
I have been building custom data classes for 2 years now and have not run into this problem.
The big difference between this custom data class and all the other ones that I have written is that unique key of the table I am accessing is an auto-incrementing Integer field type. In the past my unique key was a character type.

I am having a problem with a CustomDataClass that I created for my bizobj.
When I attempt to "update" the backend via the bizobj, the runtime flips me an error, which states:
Syntax error. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: Syntax error.

Source Error: 

Line 231:			
Line 232:			
Line 233:			this.Save(this.oAssist);
Line 234:			//this.Save(this.oAssist, mydataset, this.oAssist.TableName);
Line 235:			/////////////////////////////////////

Source File: C:\Inetpub\wwwroot\2004_gmg Web Application\QuikButtonEdit.aspx.cs    Line: 233 

Stack Trace: 

[OleDbException (0x80040e14): Syntax error.]
   System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
   System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
   OakLeaf.MM.Main.Data.mmDataAccessOleDb.SaveDataSet(DataSet ds, String tableName, String primaryKeyName, Boolean retrieveAutoIncrementPK, IDbDataAdapter dbAdapter)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey, IDbDataAdapter dbAdapter)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName)
   OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds)
My bizobj is called Assist.cs. I have added the following code so that it will use my CustomDataClass:
protected override mmDataAccessBase CreateDataAccessObject(string DataAccessName)
{
	return new AssistDataAccessOleDb(); 
}
AssistDataAccessOleDb.cs looks like this:
using System;
using System.Data;
using OakLeaf.MM.Main.Data;

namespace eCentric.gmg.Business
{
	/// <summary>
	/// Summary description for AssistDataAccessOleDb.
	/// </summary>
	public class AssistDataAccessOleDb : mmDataAccessOleDb
	{
		private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
		private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
		private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
		private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
		private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;

		private void InitializeComponent()
		{
			this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
			this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();

			//
			// oleDbDataAdapter1
			//
			this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
			this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
			this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
			this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																										new System.Data.Common.DataTableMapping("Table", "Assist", new System.Data.Common.DataColumnMapping[] {
																																																				  new System.Data.Common.DataColumnMapping("IID", "IID"), 
																																																				  new System.Data.Common.DataColumnMapping("VALUE", "VALUE"), 
																																																				  new System.Data.Common.DataColumnMapping("DISPLAYVALUE", "DISPLAYVALUE") })});




			//
			// oleDbSelectCommand1
			//
			this.oleDbSelectCommand1.CommandText = "SELECT IID, VALUE, DISPLAYVALUE FROM Assist";

			//
			// oleDbInsertCommand1
			//

			this.oleDbInsertCommand1.CommandText = "INSERT INTO Assist(IID, VALUE, DISPLAYVALUE) "
				+ "VALUES(?, ?, ?)";
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("IID", System.Data.OleDb.OleDbType.Integer, 4, "IID"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("VALUE", System.Data.OleDb.OleDbType.VarChar, 6, "VALUE"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("DISPLAYVALUE", System.Data.OleDb.OleDbType.VarChar, 12, "DISPLAYVALUE"));

			//
			// oleDbUpdateCommand1
			//
			this.oleDbUpdateCommand1.CommandText = "UPDATE Assist SET IID = ?,  VALUE = ?,  DISPLAYVALUE = ? WHERE iid = ? " ;
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("?IID", System.Data.OleDb.OleDbType.Integer, 4, "IID"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("?VALUE", System.Data.OleDb.OleDbType.VarChar, 6, "VALUE"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("?DISPLAYVALUE", System.Data.OleDb.OleDbType.VarChar, 12, "DISPLAYVALUE"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("?iid", System.Data.OleDb.OleDbType.Integer, 4, "iid"));

			//
			// oleDbDeleteCommand1
			//

			this.oleDbDeleteCommand1.CommandText = "DELETE FROM Assist WHERE iid = ?";
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("?iid", System.Data.OleDb.OleDbType.Integer, 4, "iid"));

		}

		/// <summary>
		/// Constructor
		/// </summary>
		public AssistDataAccessOleDb()
		{
			this.InitializeComponent();
		}

		/// <summary>
		/// Returns an instance of the custom data adapter
		/// </summary>
		/// <returns></returns>
		public override System.Data.IDataAdapter CreateDataAdapter()
		{
			return this.oleDbDataAdapter1;
		}
	}
}
Please read through my CustomDataClass an indicate where the potential problem is....
Any thoughts?
Dr. G.
Next
Reply
Map
View

Click here to load this message in the networking platform