StrataFrame Forum

Connection Wizard or Hardcoding datasource

http://forum.strataframe.net/Topic19243.aspx

By Mike Thomas - 9/9/2008

i am using sql server ce 3.5  my oledb provider is Microsoft.SQLSERVER.CE.OLEDB.3.5.  how do i modify appmain.vb to use this?  i don't think the connection wizard handles this but i could be wrong.  can someone step this beginner through whats necessary to hook my app up to the compact edition? 

Thanks in advance!

Mike

By Trent L. Taylor - 9/10/2008

You will not want to use the Connection Wizard in this case.  You will need to manually supply the connection string.  The Connection Wizard only works with:

  • SQL Server (no embedded editions)
  • Oracle
  • VFP
  • Access

If you need to connection to a different type of OLE database, then that is fine and SF will work, but you will have to manually supply the connection string:

MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New OleDbDataSourceItem("","My ConnectionString"))

When you do this you will place this code in the Appmain.vb SetDataSourcesMethod and then remoce the SetConnections line (as this forces the Connection Manager to be used).  Also, there is a lot of information about connection strings and setting them up manually within the help docs as well.

By Mike Thomas - 9/10/2008

Could you give me an example of what exactly i need to do Trent?  Sorry for the confusion.
By Greg McGuffey - 9/10/2008

Try this link. It provides examples of valid connection strings for SQL Server embedded edition.



http://www.connectionstrings.com/?carrier=sqlserver2005ce



You'd just plug the appropriate connection string into the line of code Trent provided:



MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New OleDbDataSourceItem("","My ConnectionString"))




Replace "My ConnectionString" with the connection string you actually want to use.



This setups a default data source with a key of "" (empty string, the default used for BOs). This goes in the SetDataSources method in AppMain.vb or program.cs (VB or C# respectively).
By Mike Thomas - 9/10/2008

here is what i am doing in appmain.vb...in the SetDataSources method i have the following code:

MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New OleDbDataSourceItem("PREMFRAME", "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\Users\michthom\Documents\Visual Studio 2008\Projects\premframev2\premframev2\premdatav2.sdf;"))

it tells me that OleDbDataSourceItem is not defined

i know i am missing something here.

By Greg McGuffey - 9/10/2008

I just searched through the object browser and I don't find this object....only datasourceitems for access, sql, oracle and vfp. That is strange. Is this in some other dll that isn't usually referenced? I also don't find anything about it in help.
By Mike Thomas - 9/10/2008

Thanks.  I hope Trent can clarify for us. 
By Keith Chisarik - 9/10/2008

I am also looking for OleDbDataSourceItem for use with SQL Compact 3.5 as discussed in this and other threads on the forum. I have a simple application that does not warrant SQL Express, I have used SQL Compact for mobile applications and would now like to use with SF for desktop.

Please point me in the right direction as I cannot find anything on this provider in SF help.

By Keith Chisarik - 9/10/2008

An overview of how to deploy to SF Compact database (.sdf) from the DDT would be great too.
By Mike Thomas - 9/11/2008

I hope someone can help soonSmile Smile
By Keith Chisarik - 9/11/2008

Mike Thomas (09/11/2008)
I hope someone can help soonSmile Smile

I'm sure someone will be along shortly with the magic answer. Hopefully like Greg said it is just an assembly we are missing (I hope). I am excited to get my new project working using compact databases, it will make deployment much easier for a relatively simple product.

The fact that Trent posted to use the OLE provider, with source code above, makes me feel good about a quick resolution.

By Trent L. Taylor - 9/11/2008

OK...let's get a couple of things cleared up here...there is not an OleDbDataSourceItem...when I posted this, I was alluding to the fact that you would be using a data source that using using the OleDbCommands.  SF comes with a base class called DbDataSourceItem.  There is not a generic OleDbDataSourceItem as each OleDbProvider may have different requirements and commands (such as Access and VFP).  But you can create your own very quickly.  Just open the SF source, and go to the Base assembly.  In that assembly there is a folder called Data\DataSourceClasses.  You will find all of the SF pre-plumbed data source classes there.  Just copy the Access or VFP source code and then go into your assembly and create your own data source item called WhateverDataSourceItem that is specific to the compact environment that you are trying to use.

Using SqlDataSourceItem on Embedded Editions
Now if I am not mistaken, if you are trying to use SQL Server Everywhere (or a compact edition of SQL Server) then you can use the SqlDataSourceItem and then specify the OLEDB provider or other supported SQL provider as part of your connection string and it will work just fine.  Ths SQLCommands should support the SQL Everywhere editions as I am pretty confident that this is the approach a number of our developers are using for this embedded data source.  But in the case that you are using something other than an SQL edition, then you will need to create the data source mentioned above.

This can also be impacted by the version of the Mobile SDK being used, etc.

Also, there is more than one way to connect to a Mobile version of SQL Server...you can use the SqlCeXXX commands and namespaces which would require you to create your own data source (mentioned above) or to use OLEDB or ODBC, which both of the latter mentioned should be able to use the standard SQLConnection and SQLCommand as well as the SqlDataSourceItem classes.

Finally, Keith, the DDT does not support a compact or embedded edition of SQL Server...this is a totally different platform and would require major changes to the DDT in order to work.

By Keith Chisarik - 9/11/2008

OK I hope the SQL data source will work, I wrote a MYSQL provider for my last project and really want to avoid ever going it again. It works but was a real pain.

As far as the DDT goes thats fine, I'll do what I did for the MYSQL provider, create a SQL Server mirror of the database just for BO Mapper.

Is adding official support for SQL Compact on the radar?

Thank you for your answers.

By Trent L. Taylor - 9/11/2008

Is adding official support for SQL Compact on the radar?

Yes...but it is a very faint blimp Smile  There are a number of other more highly demanded things ahead of this...so though this is something that will definitely be part of the framework, it may be a while.  Probably the next major release (SF 2.0).

By Keith Chisarik - 9/11/2008

Excellent, your your vacation was relaxing. Welcome back.

PS - Cowboys 21 - Eagles 30 Monday night

By Mike Thomas - 9/11/2008

copied file and renamed ...not sure what all changes need to be made as it looks very generic to any ole provider.

tried to rebuild microfour.strataframe base and got the following error...

Error 1 The command ""C:\Program Files\MicroFour\StrataFrame Source Code\MicroFour StrataFrame Base\AfterBuild.bat" "C:\Program Files\MicroFour\StrataFrame Source Code\MicroFour StrataFrame Base\bin\MicroFour StrataFrame Base.dll" "C:\Program Files\MicroFour\StrataFrame Source Code\MicroFour StrataFrame Base\bin\microfour strataframe base.xml"" exited with code 9009. microfour strataframe base

was i doing the right thing?

By Ivan George Borges - 9/11/2008

Hey Mike.

Try the following:

  1. Close down all Visual Studio Instances
  2. Open two Explorer Windows.  Navigate one to the "C:\Program Files\MicroFour\StrataFrame Source Code\MicroFour StrataFrame Base\bin" folder and the other to the "C:\Windows\Assembly" folder.
  3. select the "MicroFour StrataFrame Base.dll" from the bin folder
  4. Drag the selected file into the "c:\windows\assembly" folder (GAC)
  5. Also copy the "MicroFour StrataFrame Base.dll" and the "microfour strataframe base.xml" to the "c:\program files\common files\microfour\strataframe" folder
  6. Your assemblies will now be on the latest build.
  7. Go back into Visual Studio
By Trent L. Taylor - 9/11/2008

PS - Cowboys 21 - Eagles 30 Monday night

Well...you know, the other day Charles Hankey sent me something prior to the Browns game...and well, we know how that turned out.  So I will wait until next Tuesday before I say too much...but when the Boys win w00t ... then I will have more to say BigGrin

By Trent L. Taylor - 9/11/2008

Oh...and Ivan's suggestions look good, Mike BigGrin
By Mike Thomas - 9/12/2008

Thank you will try. 

Do you know if by getting that error that anything was rebuilt?  do i need to take out the post build event out to get it to rebuild successfully first?

Thanks again everyone!

By Trent L. Taylor - 9/12/2008

Well, Ivan was telling you how to get back to ground zero.  The AfterBuild.bat file is actually distributed with the source code, but the PostBuild event is just looking for it on the c:\ folder.  So you can copy the AfterBuild.bat to the c:\ and then it will work from that point forward.

Secondly, you should not be changing the SF source code, which it sounds like you are doing.  You should create your DbDataSourceItem in one of your assemblied, not the SF base assembly.  You NEVER want to change the SF source if you plan to ever receive another update.  This is why you want to create your own base assembly which references the SF Base and then either inherit and override logic or create your SF inherited classes there so that when you get a new version of SF it doesn't wipe out your code and require you to go back and keep putting things in.

By Keith Chisarik - 9/12/2008

I could not get OLEDB to work, if anyone does I would appreciate an email to kchisarik@sigmadatainc.com to let me know what you did but for now I have moved on based on I would rather is an ADO driver than OLEDB anyhow and I spent too much time on OLEDB already.

The provided SQLDataSourceItem will not work due to differences in features support between SQL Serevr and SQL compact. Basic stuff like schema designation, use of IDENTITY_SCOPE are not supported and must be removed from the SQL commands. I went down the road of creating a SQLCEDataSourceIitem that uses the System.Data.SqlServerCE namespace and have had good results so far. I have basic databinding and UPDATES working using the following in appmain.

MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New SqlCEDataSourceItem("", "Data Source=C:\ioivb.sdf;"))

Again, if someone out there gets either the BOMapper or SF in general to work with less effort using OLEDB, I would appreciate a heads up. If anyone is interested in the SQLCEDataSourceItem, let me know. It will only have the "_NONSP" items done, but it will work.

By Mike Thomas - 9/12/2008

BO Mapper worked fine for me against sql compact edition.  Just had to select oledb and then have the proper connection string which for me was the following

Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\Users\michthom\Documents\Visual Studio 2008\Projects\premframev2\premframev2\premdatav2.sdf

i think i don't understand the framework enough to do what trent is suggesting.  I would love if someone had a sql compact code example i could customize for my file.  I do really need to use the desktop edition so i am not sure what to do

By Keith Chisarik - 9/12/2008

Oh my. That worked on my work PC, I was trying this stuff at home last night, apparently there is a problem with my install on that box that was the cause of my issues, better late than never.

Thank you for posting this. On a PC that has a good install ( Cool ) I got OLEDB working.

1) Created OLEDBSOURCE class

2) use #1 in appmain:

MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New OLEDBSOURCE("", "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\ioivb.sdf"))

3) Change my fills to use OLEDBCommand instead of SqlCommand

 

 

By Keith Chisarik - 9/12/2008

Trent any opinion on wheher it would be worthwhile to finish the SQLCEDatasoureItem I started versus using OLEDB?
By Trent L. Taylor - 9/12/2008

Well, this would really only be something that you could answer.  It will be a while before we create an SqlCeDataSourceItem ourselves...so if you have this immediate need and do not want to use the OLEDB, then you may want to proceed.
By Mike Thomas - 9/12/2008

Kieth, not sure what you are saying....you app is now working against sql compact edition because you created your customer datasource item?
By Keith Chisarik - 9/12/2008

I am up and running yes.
By Mike Thomas - 9/12/2008

Hi Trent, if you had to develop a desktop solution for say home users - what database would you use foxpro or access?  it looks like i may not understand enough to get the framework to work with sql compact edition.  I am a past foxpro person but i wonder about using that anymore as a backend.
By Ivan George Borges - 9/12/2008

Hey Mike.

Just curious... what are your reasons for not using SQL Server Express?

By Mike Thomas - 9/12/2008

Two apps i have in mind...one is for the home market  and I was thinking i didn't want the overhead and possibly slower performance of the SQL Express if I could use compact edition.  Also, i am not sure whats involved in distributing sqlexpress to get it install properly as part of the application installation.

do you have some experience with sqlexpress and distributing?

By Trent L. Taylor - 9/13/2008

Distributing SQL Express is extremely easy.  In fact, if you use a tool like InstallAware, it is literally as easy as clicking a CheckBox and tweaking a few parameters.  We use InstallAware for our medical software and though, like any install software, there are some frustrations, one thing that they got right were the pre-reqs and installing pre-reqs.

Even if you choose to do this yourself, you can download the SQL Server Express redistributable and via command lines install it very easily.  SQL Server is also easy to test for in regards to services if you take the manual approach.  We use SQL Server Express in a high percentage of our medical software user base and so we have to test for and install SQL Server Express if needed.  This is really one of the easier parts of the install.

By Trent L. Taylor - 9/13/2008

Hi Trent, if you had to develop a desktop solution for say home users - what database would you use foxpro or access?  it looks like i may not understand enough to get the framework to work with sql compact edition.  I am a past foxpro person but i wonder about using that anymore as a backend.

If I had to choose between those two it would be Access.  FoxPro is nothing but a problem waiting for a place to happen...this comes from MANY years of experience. 

But in truth, I would not use either of these, but SQL Server Express.  I know that this post has been geared around embedded database conversation, but there is a reason that we have not yet created a data source item for this...there is generally a better solution.  I do see the benefits of a disconnected laptop for the day, etc.  But even then I would tend to lean towards SQL Server Express.  First of all, it is free.  Secondly, it is faster and a full version of SQL Server.  Additionally, you don't have to deal with data type issues.  For example, SQL Mobile doesn't have a VarChar data type but only a NVarChar (unless something has changed recently).  Not that using an NVarChar is bad, but it just might not line up exactly with the desktop structures (if you a.] have the need or b.] ever plan to have a larger version of an application).

In my opinion, and if I were hired in a capacity for consultation purposes in a situation like this, I would tell my client that they are better off developing on a full SQL Server version versus an embedded edition....I have a lot of embedded experience from years past and there are other issues that you will inevitabely run into (i.e. row locking, etc.).

By Keith Chisarik - 9/13/2008

Trent is right naturally, anything but a very simple app or disconnected feature would be better with Express.

That being said, my current project is VERY simple as far as data goes as it mostly does scanning and image manipulation, and will be single workstation only, so SQL Compact I think will be the right choice based on past experience with it.

The attachment is a very simple working sample that uses SF 1.6.6, the ADO .NET Provider for SQL Compact 3.5 (had issues with OLEDB updates I couldnt get past) included with VS2008, and the System.Data.SQLServerCE namespace used to create a SQLCEDataSourceItem. I tested with OptomisticRowVersion since that is what I use. Just slap the SDF file in the ZIP onto the root of your C drive and it should work. Good luck and I hope it helps someone.

By Trent L. Taylor - 9/14/2008

Thanks for the contribution, Keith.  You may want to add this to the user contributed samples area...I think that this would be a good fit Wink
By Marcelo Blank - 1/21/2013

Hi.

I´m having the same problem ... I need to use a Compact SLQ to a small test app.

I can´t get the connection on the app...

I´m doing this, but gives me an error when try to get the data





 private static void SetDataSources()
        {
           

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

                        MicroFour.StrataFrame.Data.DataLayer.DataSources["ATG"].ConnectionString =@"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;
                                Data Source=D:\PROJETOS\SGO\ATGConnector\ATGConn\ATGConn\Ordens.sdf;SSCEBigGrinatabase Password='123456';";
            
        }



How to set up the SQL Compact with Strataframe ?




By StrataFrame Team - 1/21/2013

What is the specific error you receive, Marcelo?  The connection string looks fine, and I'm pretty sure that the System.Data.SqlClient provider will support SQL Server CE.