Error with SqlDataSourceItem-Key


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi there,

I tried the example found in the help file to manually set up my dataconnection and first tried this:

DataLayer.DataSources.Add(New SqlDataSourceItem("", "SERVER=.\SQL2008EXPRESS;INITIAL CATALOG=MyDB; Integrated Security = True"))

This works exactly like I expected it. But then I tried to insert a key

DataLayer.DataSources.Add(New SqlDataSourceItem("MyKey", "SERVER=.\SQL2008EXPRESS;INITIAL CATALOG=MyDB; Integrated Security = True"))

which causes an error when loading a form which uses a businessobject.

Finally I tried it like in the help described

Dim lOSQL As New SqlDataSourceItem("MyKey", "SERVER=.\SQL2008EXPRESS;INITIAL CATALOG=MyDB; Integrated Security = True")

DataLayer.DataSources.Add(lOSQL)

which is the same but it is split up in 2 lines of code. This caused the error too.

Can somebody help me and tell me what I am doing wrong?

Thanks in Advance

 

Thomas

 

 

Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Thomas,



When using a DataSourceKey in the connection like you are doing, you also have to tell the BO to use that key, so in the BO fill the property DataSourceKey with the value of the key you are using, in this case MyKey

Edhy Rijo

Thomas Holste
Thomas Holste
StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)StrataFrame User (370 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Edhy,

thanks a lot for your help. Adding the datasourcekey did it. Setting it in the property-sheet on the form worked fine and now I'll try setting it in the constructorof the bo.

Best regards

Thomas

Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
You are welcome Thomas.



With the DataSourceKey logic, StrataFrame allow us to connect to multiple databases in a single application, this way you can have an application talking by default to MS-SQL and some other business objects talking to MySQL, ORACLE, VFP, Access or whatever without the user knowing it. This is a very, very powerful feature.

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thomas, rather than setup it up in the constructor of the BO or using the DataSourceKey of the instance on the form, use the designer of the BO itself (just double click on a Bo, the designer opens, hit F4 (to open properties) and set key there. The it is automatically set whenever it used.



You'd use the form override if a particular form needed to switch data sources or you could use code override if more complicated cases.
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