By Daniel Essin - 2/4/2006
I'm creating a service that needs to access several tables in a database. The service project includes a Strataframe Business Object Library but (obviously) no strataframe application. I have several questions:
1 - is the following correct:
System.Data.SqlClient.SqlConnectionStringBuilder loBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder();
loBuilder.DataSource = _DdmServer;
loBuilder.InitialCatalog = _DdmDatabase;
loBuilder.UserID = _DdmLogin;
loBuilder.Password = _DdmPassword;
SqlDataSourceItem loNewDB;
//-- Create a new data source item
loNewDB = new SqlDataSourceItem(_DdmDatabase, loBuilder.ToString());
//-- Add the new database to the data source collection
DataLayer.DataSources.Add(loNewDB);
2 - How do I make sure that a data layer is created so that the last statement above will acturlaly refer to something?
|
By StrataFrame Team - 2/6/2006
DataLayer.DataSources is a shared (static) property, so it will always exist... You don't create an instance of the DataLayer, and then reference the DataSources property on it, you just access the shared DataSources property on the DataLayer class, just like it's written. The rest of your code looks good. Just make sure you call that code within the ServiceStart method (or whatever name it has) to ensure that the data source is added to that static collection.
|
By Daniel Essin - 2/7/2006
thanks
|
|