|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Can you put a break point immediately after the ConnectionManager.SetConnections() call within the SetDataSources() method? In your watch window there, you will want to check the value of this: MicroFour.StrataFrame.Data.DataBasics.DataSources[""] It should be an object of type VfpDataSourceItem, not SqlDataSourceItem.
|
|
|
|
|
Ger Cannoll
|
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
Hi Ben, code taken from program.cs: ConnectionManager.AddRequiredDataSourceItem("", "Visual Fox Pro Connection", DataSourceTypeOptions.VisualFoxPro, @"C:\KERDEMO\DFS.dbc", "This connection is used by YourApp.");
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
For some reason, it's adding an SqlDataSourceItem and not a VfpDataSourceItem. In the call to AddRequiredDataSourceItem, is the DataSourceTypeOptions set to VisualFoxPro or SqlServer? If you need, you can paste the code from the SetDataSources() method out here again.
|
|
|
|
|
Ger Cannoll
|
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
Hi Ben. I did as you suggested and it is now nop longer looking for Mydatabase! However, I am now getting an error trying to open the actual database. This happens on the save of a maintenance Form. I can access this database fine from VFP. I am still puzzled by the 'Login' reference as I dont have a login screen set up anywhere !! BusinessLayerException An error occurred while saving an the data to the server. DataLayerSavingException Cannot open database "C:\KERDEMO\DFS.dbc" requested by the login. The login failed. Login failed for user 'GERARDXP\Ger O Carroll'. SqlException Cannot open database "C:\KERDEMO\DFS.dbc" requested by the login. The login failed. Login failed for user 'GERARDXP\Ger O Carroll'. Source : MicroFour StrataFrame Business Stack Trace: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand) at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler) at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams) at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save() at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e) at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Most likely, you ran the application once before you commented out the AddRequiredDataSourceItem for SQL that requested MyDatabase. So, your application still thinks it needs MyDatabase. Right after the SetConnections() method is called within the SetDataSources() method, you can add a call to ConnectionManager.ShowAvailableConnections(). This will popup the connection string builder and allow you to delete the configured connection. Then re-run it without call to ShowAvailableConnections() and you can re-configure the connection string properly with for the FoxPro connection.
|
|
|
|
|
Trent Taylor
|
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
This is just a standard SQL connection error. The user who you are attempting to use cannot login or access the SQL Server connection for some reason. If you'll notice, it is trying to connect to SQL Server and I do not see that you have specified a SQL connection. Are you reusing this application key: StratFarmeSmaApp? If so, then this could be your problem. Change this key by adding a "1" to the end or something and it should force the connection wizard to come back up. Make sure that you are pointing to the VFP database and see if the error persists. ConnectionManager.ApplicationKey = "StratFarmeSmaApp1"; If this doesn't work, remove the ConnectionManager.SetConnections() in the SetDataSOurces and hard code your connection and see if the error persists. MicroFour.StrataFrame.Data.DataBasics.DataSOurces.Add(New VFPDataSourceItem("","provider=VFPOLEDB;data source=C:\\MyDatabase.dbc")); In fact, the first thing you may want to do is turn on database debugging so you can see exactly what is happening. After the ConnectionManager.SetConnections() method, add this code: MicroFour.StrataFrame.Data.DataBasics.DataSources[0].SetDebugOn(@"c:\Output.html",true); Run the application again and it will log every piece of the data interaction. One the error occurs, bring up the HTML file and you will be able to see the connection and exactly what happened.
|
|
|
|
|
Ger Cannoll
|
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
I did not do antything to set security on (would it be on by default ?) Trace as follows: BusinessLayerException An error occurred while saving an the data to the server. DataLayerSavingException Cannot open database "MyDatabase" requested by the login. The login failed. Login failed for user 'GERARDXP\Ger O Carroll'. SqlException Cannot open database "MyDatabase" requested by the login. The login failed. Login failed for user 'GERARDXP\Ger O Carroll'. Source : MicroFour StrataFrame Business Stack Trace: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand) at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler) at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams) at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey) at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save() at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e) at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
Trent Taylor
|
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
Are you trying to implement Security? You will have to give me more information to go off of as I have never even heard of this message outside of this context. Can you give me the stack trace and the inner exceptions? Thanks.
|
|
|
|
|
Ger Cannoll
|
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
The only rferance to MyDatabase in the main program is commented out: Below is acopy of Proram.cs using MicroFour.StrataFrame.Application;using MicroFour.StrataFrame.Data;using System;using System.Collections.Generic;using System.Windows.Forms;namespace StratFarmeSmaApp{ static class Program{ /// <summary>/// The main entry point for the application./// </summary>[ STAThread]static void Main(){ //-- Enable visual styles on the applicationApplication.EnableVisualStyles();//-- Add event handlers for the application eventsStrataFrameApplication.ShowGateway +=new StrataFrameApplication.ShowGatewayEventHandler(ShowGateway); StrataFrameApplication.InitializingApplication +=new StrataFrameApplication.InitializingApplicationEventHandler(InitApplication); StrataFrameApplication.SetDataSources +=new StrataFrameApplication.SetDataSourcesEventHandler(SetDataSources); StrataFrameApplication.UnhandledExceptionFound +=new StrataFrameApplication.UnhandledExceptionFoundEventHandler(UnhandledExceptionFound); StrataFrameApplication.ShowLoginAndInitializeForm +=new StrataFrameApplication.ShowLoginAndInitializeFormEventHandler(ShowLoginAndInitMainForm); //-- Run the applicationStrataFrameApplication.RunApplication();} /// <summary>/// Gets the connection string if the application will use a custom method to aquire the connection/// string rather than the StrataFrame Connection String Manager (optional)/// </summary>/// <remarks></remarks>private static void SetDataSources(){ // ToDo: 1) Set the connection information below including the connection application settings and the// required settings information and then call the ConnectionManager's SetConnections() method.//// OR//// 2) Manually set the DataSourceItems on the DataSources collection below.ConnectionManager.AddRequiredDataSourceItem("", "Visual Fox Pro Connection", DataSourceTypeOptions.VisualFoxPro, @"C:\KERDEMO\DFS.dbc", "This connection is used by YourApp.");// -- You can set as many data sources as necessary. The business objects use the data source specified// by their DataSourceKey property (defaults to "").//------------------------------------// Using the Connection Manager//------------------------------------//-- Set the information specific to this application and the data sources// The application key:ConnectionManager.ApplicationKey = "StratFarmeSmaApp";ConnectionManager.ApplicationDefaultTitle = "StratFarmeSmaApp Connection";ConnectionManager.ApplicationDefaultDescription = "This application connection is used by StratFarmeSmaApp";//-- Set the required data source information so that the ConnectionManager can gather it// SQL Connection// ConnectionManager.AddRequiredDataSourceItem("", "SQL Connection",// DataSourceTypeOptions.SqlServer, "MyDatabase", "This connection is used by StratFarmeSmaApp.");// Oracle Connection//ConnectionManager.AddRequiredDataSourceItem("", "Oracle Connection", // DataSourceTypeOptions.Oracle, "", "This connection is used by StratFarmeSmaApp.");// Access Connection//ConnectionManager.AddRequiredDataSourceItem("", "Access Connection", // DataSourceTypeOptions.MicrosoftAccess, "", "This connection is used by StratFarmeSmaApp.");// FoxPro Connection//ConnectionManager.AddRequiredDataSourceItem("", "Visual Fox Pro Connection", // DataSourceTypeOptions.VisualFoxPro, "", "This connection is used by StratFarmeSmaApp.");//-- Make the call to SetConnections which will gather the connection information, show the connection wizard// if needed and set the DataSources collection on the DataLayer class.ConnectionManager.SetConnections();//------------------------------------// Setting the data sources manually//------------------------------------//-- SQL Server//DataLayer.DataSources.Add(new SqlDataSourceItem("", "myconnectionstring"));//-- Oracle//DataLayer.DataSources.Add(new OracleDataSourceItem("", "myconnectionstring"));//-- Microsoft Access//DataLayer.DataSources.Add(new AccessDataSourceItem("", "myconnectionstring"));//-- Visual Fox Pro//DataLayer.DataSources.Add(new VfpDataSourceItem("", "myconnectionstring"));} /// <summary>/// Shows the "Gateway" form (a custom form that gives the user a choice to launch different components/// within the application) (optional)/// </summary>/// <param name="e"></param>/// <remarks></remarks>private static void ShowGateway(ShowGatewayEventArgs e){ //-- Inform the application to not show the "Gateway" form again after the main form has closede.ShowGatewayAfterMainFormClose = false;} /// <summary>/// Shows a login form before a main form is shown and allows security to be checked before the application/// launches the main form (optional)/// </summary>/// <param name="e"></param>/// <remarks></remarks>private static void ShowLoginAndInitMainForm(ShowLoginAndInitFormEventArgs e){ //-- ToDo: add any code to show a login form and authenticate the user// e.LoginSuccessful = ?} /// <summary>/// Provides a centralized location to add any initialization parameters that need to be set before/// the application is loaded and defines the form types used as main forms by the application/// </summary>/// <param name="e"></param>/// <remarks></remarks>private static void InitApplication(InitializingApplicationEventArgs e){ //-- Add the main form type//-- If more than one form is added to the collection, they can be chosen by showing a "Gateway" form// and supplying the index of the form to show (At least 1 form type must be added to the collectione.Forms.Add( typeof(StratFarmeSmaApp.Form2));//-- ToDo: Add any extra application initializationMicroFour.StrataFrame.UI. Localization.MessageKeyType = MicroFour.StrataFrame.Messaging.MessageKeyDataType.XML;MicroFour.StrataFrame.UI. Localization.MessageLocaleID = MicroFour.StrataFrame.UI.Localization.GetActiveLanguage("StratFarmeSmaApp", "", false); ;} /// <summary>/// Catches any unhandled exception within the application and provides a place to log the information/// </summary>/// <param name="e"></param>/// <remarks></remarks>private static void UnhandledExceptionFound(UnhandledExceptionFoundEventArgs e){ //-- ToDo: add any error logging required. To prevent the StrataFrame ApplicationErrorForm from showing,// set:// e.Handled = true} } }
|
|
|
|
|
Trent Taylor
|
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
The MyDatabase is the default database name specified in the AddRequiredDataSource in the AppMain.vb or program.cs file. You need to specify your database in it's place. You can find this in the SetDataSources method in the AppMain.vb or Program.cs file.
|
|
|
|