Database Connection Problems


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
After installation, I was able to successfully create a business object and map it to a table on my remote database.  A new form was created, the business object attached and some fields slapped on for testing.  No errors upon the build; however, if I run the debugger, the application fails nearly immediately with some such statement that my DataLayer is out of whack.  If I goof around with the program.cs file, I can get a database connection popup to occur when I start the app...it is looking for the "missing" connection information:  server name, authentication, database name.  If I provide all of that, then I get an unathentication error.  What am I doing wrong?  I am going through the tutorial, but any kind of hint would be helpful on this...thanks!

Bill

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
As I fiddle with the settings, I regularly get this error message:

DataLayerException
  An error occurred while creating a new DataLayer for the business object.
DataLayerException
  The DataSourceKey [] is not defined.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Data.DataLayer.Create(BusinessLayer BusinessObject, ISynchronizeInvoke SyncObject, Boolean CheckDesignTime)
   at MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer()
   at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.FillAll(Int32 ProjectPK)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.RetrieveSecurityPreferences()
   at AspireSF.Program.InitApplication(InitializingApplicationEventArgs e) in C:\Aspire Projects\AspireSF\AspireSF\Program.cs:line 161
   at MicroFour.StrataFrame.Application.StrataFrameApplication.Raise_InitializingApplication(InitializingApplicationEventArgs e)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
   at AspireSF.Program.Main() in C:\Aspire Projects\AspireSF\AspireSF\Program.cs:line 40
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You are not setting up the connection string to which the business object needs to communicate with your data correctly.  First, you need to understand the DataSourceKey, there is a lot of documentation to give you more details, but in short, each connection string will have a unique DataSourceKey.  You can then set the property of the business object (DataSourceKey) to the data source to which it needs to connect.  By default, all BOs will assume default (empty) which is fine in most cases.

You can use the ConnectionStringWIzard or manually set the connection string.  The ConnectionStringWizard requires that you setup the connection that are required (RequiredDataSourceItem).  This is done in the program.cs (or Appmain.vb).  When the SetConnections method is called in the program.cs, it looks to see if an active connection string has been established for the application using the ApplicationKey (this will basically uniquely identify your application from another and pull the connection string for that application).  This too is set in the program.cs in the SetDataSources method.  The second option is to manually set your connection string through the DataBasics.DataSources collection (this is the same thing that gets set through the Connection wizard).

More than likely you have a connection string that is pointing to the wrong database.  Make sure that the AddRequiredDataSourceItem has the correct database name supplied.  If the connection string is already setup then the wizard will not appear automatically but you can re-display it manually.  Again, refer to the docs on the Connection String Manager as it will show you how all of this works.

Finally, AND MOST IMPORTANTLY it appears the you are changing the connection string settings for your development environment.  The Database Connection from the StrataFrame menu is NOT the connection used when you run your application.  This is what StrataFrame uses during the design-time....so once you get this set and working just leave it be as it has nothing to do with your run-time connections.  All of this is set in the SetDataSources of the program.cs or AppMain.vb file.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Ok...I blew away that first application attempt.  I thought I would start over, just in case I missed something on the first pass.  So far, I have not even created a business object.  Hitting F5...alas!  I am getting this message now, after entering the valid connection information:

SqlException
  Invalid object name 'dbo.SFSPreferences'.

Source     : .Net SqlClient Data Provider

Stack Trace:
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   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.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, Boolean RegisterNotification)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.FillAll(Int32 ProjectPK)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.RetrieveSecurityPreferences()
   at AspireSF.Program.InitApplication(InitializingApplicationEventArgs e) in C:\Aspire Projects\AspireSF\AspireSF\Program.cs:line 161
   at MicroFour.StrataFrame.Application.StrataFrameApplication.Raise_InitializingApplication(InitializingApplicationEventArgs e)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
   at AspireSF.Program.Main() in C:\Aspire Projects\AspireSF\AspireSF\Program.cs:line 40
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
It looks like you are using the SF security project and you haven't setup the security db/connection. To do this you'd need to deploy the security tables/views (from DDT, if you have that...the easiest way...by far) and then setup the security key in the SetDataSources event handler...and maybe some other stuff I can't remember off the top of my head. Unsure



However, I'm guessing that right now, you just need to start simple. So, blow away this attempt too Pinch then start over, but use the normal SF project (the without security). I think you'll be on your way then.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Blow it away?! w00t  After all that non-work that I did?!!?  BigGrin

No prob.  I will try that out.  I guess I can add the security later (after I figure out the important stuff).

Thanks,
Bill

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Does the BO database(s) have to reside on the same server as the StrataFrame (design-time) database?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Does the BO database(s) have to reside on the same server as the StrataFrame (design-time) database?

No.  The two are unrelated.  If you are referring to the database to which your BOs will communicate, this database can reside wherever you may need it.  The StrataFrame database is only for design-time and has no effect on the run-time stuff.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
This line seems important to the accessibility of the data for the business object:

ConnectionManager.AddRequiredDataSourceItem("", "SQL Connection", DataSourceTypeOptions.SqlServer, "MyDatabase", "This connection is used by AspireSF.");

Even if I changed the "MyDatabase" to the proper name, how does this RequiredDataSourceItem know where the server is?

In addition, how does the following line play into all of this:

DataLayer.DataSources.Add(new SqlDataSourceItem("", "myconnectionstring"));

Sorry for my confusion on this...I have messed around with these settings, but have not found a successful combination, yet.

Thanks!
Bill

 


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I copied the connection string from my Business Object Mapper project properties window into the DataLayer.DataSources.Add method.  It seems to be working at the moment...but, I am not sure why.  The customersBO1 object on the form has an empty string in the DataSourceKey field.  Also, I had no dialog this time asking me to connect to the SQL Server.  Somehow, this change made a difference.  For the time being, it is a mystery to me.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search