Access data copy


Author
Message
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi,

I am a little lost in the documentation, not being sure what I need to do in the following circumstance. I am trying to open an access daatabase so that I can copy the data to the defaulted sql server database which has a structure change. My points are as follows:

1) I'm trying to use the BOM to create BO on the access database, so far no luck (an earlier topic)

2) Assuming I can create a BO and link it in, I'm not sure how, progamatically, I can connect to the Access database. My application allows me to point to the database so that I can pass its full filepath to a conncetion string. Do you need to supply the entire connection string or are there Strataframe fuctions that would obtain the Povider to which I can append the remainder of the string.

3) What function should I use to add the database to the collection. I realise that I need to associate a predefined DataAccessKey to the connection which is carried onto the BO which will be used to obtain the data.

I would appreciate any help,

Many thanks

Replies
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi Trent,

I have just checked the database connections again and found that the database defined is the Stratframe database and not my exprected database. When I try and edit, the database control seems to be permanently disabled thus preventing me from selecting the appropriate database.

In this appl;ication I have used the standard SetDataSource methiod to open the main sql database and I am selecting an access database from within a separate form from which I intend to copy data into the sql database.

Not sure if this helps.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Ian,



The Database Connection specified through the StrataFrame menu is for a StrataFrame database only which is used for design time. The Connection Wizard has the ability to disable this and we implemented this a long time ago to prevent people from changing this to their run-time database because it was a common forum issue.



I would suggest deleting the connections table and then starting over. Just delete the connections.dat and appkeys.dat. If you are running Vista you will find it here:



C:\ProgramData\MicroFour\ConnectionData




Once you delete these files, go back into Visual Studio and you will be prompted to connect to the StrataFrame database again. This may also clear out any "junk" you have been dealing with on your access database and allow you to start fresh.
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi Trent,

Thanks for that peice of information. It was going to be my next question!

Regards

Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi,

I have deleted the connection.dat and appkeys.dat files to reset the connections wizard. I have changed my SetDataSources method to open an Access database. This seems to work fine. When I try to execute a FillCommand in my BO I get the exception:

InvalidCastException
  Unable to cast object of type 'System.Data.OleDb.OleDbConnection' to type 'System.Data.SqlClient.SqlConnection'.

Source     : System.Data

Stack Trace:
   at System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection value)
   at System.Data.Common.DbCommand.set_Connection(DbConnection value)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, Boolean RegisterNotification)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
   at ConfigHLS.DetailsBO.FillDetailsByTableId(Int32 tableId) in E:\HLS Pro.Net Development\ConfigHLS\BusinessObjects\DetailsBO.cs:line 87
   at ConfigHLS.Forms.DetailsForm.detailsBO1_ParentFormLoading() in E:\HLS Pro.Net Development\ConfigHLS\Forms\DetailsForm.cs:line 258
   at MicroFour.StrataFrame.Business.BusinessLayer.raise_ParentFormLoading()
   at MicroFour.StrataFrame.Business.BusinessLayer.OnParentFormLoading()
   at MicroFour.StrataFrame.Business.BusinessLayer.RaiseParentFormLoadingEvent()
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.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)

Am I using the Connections Wizard incorrectly.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Instead of using the connection wizard in your app just manually specify the connection. I don't think that you have your connection type setup as Access but rather SQL.



Remove the SetConnections() line and just add a manual connection string:



MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(new AccessDataSourceItem(...))




But most likely, you have your required data source set to SQL Server instead of Access which is causing the issue.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ian Hammond - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Ian Hammond - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Ian Hammond - 16 Years Ago
                         It would help if you provided a stack trace...somewher in your code...
Trent L. Taylor - 16 Years Ago
                             Does this help: System.InvalidCastException was unhandled by user...
Ian Hammond - 16 Years Ago
                                 Hi Trent, I have just checked the database connections again and...
Ian Hammond - 16 Years Ago
                                     Ian,

The Database Connection specified through the...
Trent L. Taylor - 16 Years Ago
                                         Hi Trent, Thanks for that peice of information. It was going to be my...
Ian Hammond - 16 Years Ago
                                             Hi, I have deleted the connection.dat and appkeys.dat files to reset...
Ian Hammond - 16 Years Ago
                                                 Instead of using the connection wizard in your app just manually...
Trent L. Taylor - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search