Typed DataSets in VS2005

P

Peter Bradley

Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new DataSet
designer, but with the ability to configure the connection string via a
config file? The designer seems to hard-code the connection string into the
dataset itself, which just can't be right.

The typed DataSets created by VS2005 comes with a dll.config file that looks
as though it's trying to do something like that, and which is put with the
executable at compile time, but altering the connection string in there
doesn't appear to have any effect. We've seen lots of people asking this
question, but haven't found anyone answering it yet.


Thanks in advance





Peter
 
C

Champika Nirosh

VSS 2005 support auto generating the dataaccess layer .. and in that case
you are free to change the code where it hardcode the connection string so
that it will read it from a config file (obviously you have to change the
code again if you have to create/ edit the dataset again.

In my view point the automatically generated code is very good if you are
heading toward a quick concept demo or a working prototype.. but if you are
looking to develop a real extensible large-scale system, then I rather
advice you to have your own data access layer, indeed you may have some
assistance from the Data access Applcation Blocks or enterprise library.
There you will get that chance of developing a flexible dataaccess layer.. I
am telling this with my experience and if you go with the auto geneated code
you will at times drive in to bottleneck of your code..

Nirosh.
 
P

Peter Bradley

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data access
layer - which we code ourselves and which uses many typed datasets. At
least that was the case until now. If typed datasets now have the
connection string hard coded into them, we'll definitely not be using them
any more - for security reasons apart from anything else.


Peter
 
C

Champika Nirosh

You mean to say that just creating a typed DataSet via VSS IDE add the
connection string to it??

Am I missing some thing here.. ?? can anyone else assist me here..??

Nirosh.
 
C

Champika Nirosh

I am pretty sure that you are doing some thing wrong here.. can you just
create a seperate type dataset and confirm that it add a connection string
too?? Why it need to have a connection string hradcoded to create a typed
dataset for you.. but it you select the optipon of autocreating the DAL then
yes it does add a hardcoded connection string to the dataset..

Nirosh.
 
C

Champika Nirosh

Oh yeas that is just to synchup wth the database.. ok I understand you now

cann't you delete it after you create the type dataset..

I am sorry to take you this far without understanding the problem..

Let me check it and let you know result

Nirosh.
 
P

Peter Bradley

Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly"
Name="aservernamedevConnectionString (Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter" Name="atablename"
UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True"
UserGetMethodName="GetData" UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename] ([mailbox],
[storage_group], [server]) VALUES (@mailbox, @storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server FROM
dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET [mailbox] =
@mailbox, [storage_group] = @storage_group, [server] = @server WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetDataBy" GeneratorSourceName="FillBy"
GetMethodModifier="Public" GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True"
UserGetMethodName="GetDataBy" UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName=""
DataSourceName="" DbType="Int32" Direction="ReturnValue"
ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0"
Size="4" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>
 
P

Peter Bradley

Thanks, Nirosh.

You might like to look at the .xsd file I've posted lower down in this
thread.


Peter
 
C

Champika Nirosh

So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Peter Bradley said:
Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly"
Name="aservernamedevConnectionString (Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter" Name="atablename"
UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename] ([mailbox],
[storage_group], [server]) VALUES (@mailbox, @storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server FROM
dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET [mailbox] =
@mailbox, [storage_group] = @storage_group, [server] = @server WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName=""
DataSourceName="" DbType="Int32" Direction="ReturnValue"
ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0"
Size="4" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Peter Bradley said:
Nirosh. That's what we've done. That's why I'm asking the question.


Peter
 
P

Peter Bradley

If it was just for its internal use, I wouldn't be bothered. I've tried it
out, and there is no way of changing that setting via a configuration file
once the dll has been deployed (and put in the GAC in our case) that has
worked for me. If you can suggest a way, I'd be very grateful.


Peter

Champika Nirosh said:
So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Peter Bradley said:
Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox, @storage_group,
@server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server
FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET [mailbox] =
@mailbox, [storage_group] = @storage_group, [server] = @server WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName=""
DataSourceName="" DbType="Int32" Direction="ReturnValue"
ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0"
Size="4" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Peter Bradley said:
Nirosh. That's what we've done. That's why I'm asking the question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you just
create a seperate type dataset and confirm that it add a connection
string too?? Why it need to have a connection string hradcoded to create
a typed dataset for you.. but it you select the optipon of autocreating
the DAL then yes it does add a hardcoded connection string to the
dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed datasets
now have the connection string hard coded into them, we'll definitely
not be using them any more - for security reasons apart from anything
else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in that
case you are free to change the code where it hardcode the connection
string so that it will read it from a config file (obviously you have
to change the code again if you have to create/ edit the dataset
again.

In my view point the automatically generated code is very good if you
are heading toward a quick concept demo or a working prototype.. but
if you are looking to develop a real extensible large-scale system,
then I rather advice you to have your own data access layer, indeed
you may have some assistance from the Data access Applcation Blocks
or enterprise library. There you will get that chance of developing a
flexible dataaccess layer.. I am telling this with my experience and
if you go with the auto geneated code you will at times drive in to
bottleneck of your code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new
DataSet designer, but with the ability to configure the connection
string via a config file? The designer seems to hard-code the
connection string into the dataset itself, which just can't be
right.

The typed DataSets created by VS2005 comes with a dll.config file
that looks as though it's trying to do something like that, and
which is put with the executable at compile time, but altering the
connection string in there doesn't appear to have any effect. We've
seen lots of people asking this question, but haven't found anyone
answering it yet.


Thanks in advance





Peter
 
C

Champika Nirosh

To my understanding that value is *only* use for its internal stuff such as
seemlessly synchup with the database.. but not known that it is used for
anything once you deply the solution..I have develop many app that has auto
generated typed dataset and deployed them in many different env and never
bother this value.. I always taken the connection string via the config file
and use it in the dataaccess layer to communicate with the database..

Nirosh.

Peter Bradley said:
If it was just for its internal use, I wouldn't be bothered. I've tried
it out, and there is no way of changing that setting via a configuration
file once the dll has been deployed (and put in the GAC in our case) that
has worked for me. If you can suggest a way, I'd be very grateful.


Peter

Champika Nirosh said:
So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Peter Bradley said:
Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox, @storage_group,
@server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server
FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET [mailbox]
= @mailbox, [storage_group] = @storage_group, [server] = @server WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@mailbox" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="mailbox" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@storage_group" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@server" Precision="0" ProviderType="VarChar" Scale="0"
Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_mailbox" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName=""
DataSourceName="" DbType="AnsiString" Direction="Input"
ParameterName="@Original_server" Precision="0" ProviderType="VarChar"
Scale="0" Size="0" SourceColumn="server" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName=""
DataSourceName="" DbType="Int32" Direction="ReturnValue"
ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int"
Scale="0" Size="4" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you
just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select the
optipon of autocreating the DAL then yes it does add a hardcoded
connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed datasets
now have the connection string hard coded into them, we'll definitely
not be using them any more - for security reasons apart from anything
else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in that
case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to create/
edit the dataset again.

In my view point the automatically generated code is very good if
you are heading toward a quick concept demo or a working prototype..
but if you are looking to develop a real extensible large-scale
system, then I rather advice you to have your own data access layer,
indeed you may have some assistance from the Data access Applcation
Blocks or enterprise library. There you will get that chance of
developing a flexible dataaccess layer.. I am telling this with my
experience and if you go with the auto geneated code you will at
times drive in to bottleneck of your code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new
DataSet designer, but with the ability to configure the connection
string via a config file? The designer seems to hard-code the
connection string into the dataset itself, which just can't be
right.

The typed DataSets created by VS2005 comes with a dll.config file
that looks as though it's trying to do something like that, and
which is put with the executable at compile time, but altering the
connection string in there doesn't appear to have any effect.
We've seen lots of people asking this question, but haven't found
anyone answering it yet.


Thanks in advance





Peter
 
P

Peter Bradley

OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're talking
about another config file, how is it accessed in code and how is it passed
to the DataSet?

I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error was
generated and the data was retrieved from the development database (as in
the hard-coded strings).


Peter

Champika Nirosh said:
To my understanding that value is *only* use for its internal stuff such
as seemlessly synchup with the database.. but not known that it is used
for anything once you deply the solution..I have develop many app that has
auto generated typed dataset and deployed them in many different env and
never bother this value.. I always taken the connection string via the
config file and use it in the dataaccess layer to communicate with the
database..

Nirosh.

Peter Bradley said:
If it was just for its internal use, I wouldn't be bothered. I've tried
it out, and there is no way of changing that setting via a configuration
file once the dll has been deployed (and put in the GAC in our case) that
has worked for me. If you can suggest a way, I'd be very grateful.


Peter

Champika Nirosh said:
So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server
FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET [mailbox]
= @mailbox, [storage_group] = @storage_group, [server] = @server WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName=""
DataSourceName="" DbType="Int32" Direction="ReturnValue"
ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int"
Scale="0" Size="4" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you
just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select the
optipon of autocreating the DAL then yes it does add a hardcoded
connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed datasets
now have the connection string hard coded into them, we'll
definitely not be using them any more - for security reasons apart
from anything else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to create/
edit the dataset again.

In my view point the automatically generated code is very good if
you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own data
access layer, indeed you may have some assistance from the Data
access Applcation Blocks or enterprise library. There you will get
that chance of developing a flexible dataaccess layer.. I am
telling this with my experience and if you go with the auto
geneated code you will at times drive in to bottleneck of your
code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new
DataSet designer, but with the ability to configure the connection
string via a config file? The designer seems to hard-code the
connection string into the dataset itself, which just can't be
right.

The typed DataSets created by VS2005 comes with a dll.config file
that looks as though it's trying to do something like that, and
which is put with the executable at compile time, but altering the
connection string in there doesn't appear to have any effect.
We've seen lots of people asking this question, but haven't found
anyone answering it yet.


Thanks in advance





Peter
 
P

Peter Bradley

OK. Here's what I tried.

The hard-coded values are pointing to our development database. So I
created the new table in our live database and created the stored procedure
there as well.

Then I altered the dll.config file that VS2005 puts into the same folder as
the executable to point to the live database, and ran the client.

The data is still returned from the development database.

Can you tell me what I'm doing wrong?


Peter

Peter Bradley said:
OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're talking
about another config file, how is it accessed in code and how is it passed
to the DataSet?

I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error was
generated and the data was retrieved from the development database (as in
the hard-coded strings).


Peter

Champika Nirosh said:
To my understanding that value is *only* use for its internal stuff such
as seemlessly synchup with the database.. but not known that it is used
for anything once you deply the solution..I have develop many app that
has auto generated typed dataset and deployed them in many different env
and never bother this value.. I always taken the connection string via
the config file and use it in the dataaccess layer to communicate with
the database..

Nirosh.

Peter Bradley said:
If it was just for its internal use, I wouldn't be bothered. I've tried
it out, and there is no way of changing that setting via a configuration
file once the dll has been deployed (and put in the GAC in our case)
that has worked for me. If you can suggest a way, I'd be very grateful.


Peter

So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Just in case anyone else has any doubts, here's the generated xsd file
(slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server
FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET
[mailbox] = @mailbox, [storage_group] = @storage_group, [server] =
@server WHERE (([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox =
@mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="storage_group"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox"
/>
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True"
AutogeneratedName="" DataSourceName="" DbType="Int32"
Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10"
ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you
just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select the
optipon of autocreating the DAL then yes it does add a hardcoded
connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed datasets
now have the connection string hard coded into them, we'll
definitely not be using them any more - for security reasons apart
from anything else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to
create/ edit the dataset again.

In my view point the automatically generated code is very good if
you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own data
access layer, indeed you may have some assistance from the Data
access Applcation Blocks or enterprise library. There you will get
that chance of developing a flexible dataaccess layer.. I am
telling this with my experience and if you go with the auto
geneated code you will at times drive in to bottleneck of your
code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new
DataSet designer, but with the ability to configure the
connection string via a config file? The designer seems to
hard-code the connection string into the dataset itself, which
just can't be right.

The typed DataSets created by VS2005 comes with a dll.config file
that looks as though it's trying to do something like that, and
which is put with the executable at compile time, but altering
the connection string in there doesn't appear to have any effect.
We've seen lots of people asking this question, but haven't found
anyone answering it yet.


Thanks in advance





Peter
 
P

Peter Bradley

Sorry to follow up on my own post, but a little light may have just lit up.

The table adapter created with the typed dataset has a Connection property.
If I set that, I might get somewhere. It's too late now, tonight. I'll try
it out in the morning and let the list know how I get on, in case it helps
someone else.



Cheers





Peter



Peter Bradley said:
OK. Here's what I tried.

The hard-coded values are pointing to our development database. So I
created the new table in our live database and created the stored
procedure there as well.

Then I altered the dll.config file that VS2005 puts into the same folder
as the executable to point to the live database, and ran the client.

The data is still returned from the development database.

Can you tell me what I'm doing wrong?


Peter

Peter Bradley said:
OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're
talking about another config file, how is it accessed in code and how is
it passed to the DataSet?

I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error
was generated and the data was retrieved from the development database
(as in the hard-coded strings).


Peter

Champika Nirosh said:
To my understanding that value is *only* use for its internal stuff such
as seemlessly synchup with the database.. but not known that it is used
for anything once you deply the solution..I have develop many app that
has auto generated typed dataset and deployed them in many different env
and never bother this value.. I always taken the connection string via
the config file and use it in the dataaccess layer to communicate with
the database..

Nirosh.

If it was just for its internal use, I wouldn't be bothered. I've
tried it out, and there is no way of changing that setting via a
configuration file once the dll has been deployed (and put in the GAC
in our case) that has worked for me. If you can suggest a way, I'd be
very grateful.


Peter

So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Just in case anyone else has any doubts, here's the generated xsd
file (slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public"
FillMethodName="Fill" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetData"
GeneratorSourceName="Fill" GetMethodModifier="Public"
GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox
= @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group, server
FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET
[mailbox] = @mailbox, [storage_group] = @storage_group, [server] =
@server WHERE (([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox
= @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox"
/>
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server" />
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">

<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True"
AutogeneratedName="" DataSourceName="" DbType="Int32"
Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10"
ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the
question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you
just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select the
optipon of autocreating the DAL then yes it does add a hardcoded
connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed
datasets now have the connection string hard coded into them,
we'll definitely not be using them any more - for security reasons
apart from anything else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to
create/ edit the dataset again.

In my view point the automatically generated code is very good if
you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own
data access layer, indeed you may have some assistance from the
Data access Applcation Blocks or enterprise library. There you
will get that chance of developing a flexible dataaccess layer..
I am telling this with my experience and if you go with the auto
geneated code you will at times drive in to bottleneck of your
code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts on
configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's new
DataSet designer, but with the ability to configure the
connection string via a config file? The designer seems to
hard-code the connection string into the dataset itself, which
just can't be right.

The typed DataSets created by VS2005 comes with a dll.config
file that looks as though it's trying to do something like that,
and which is put with the executable at compile time, but
altering the connection string in there doesn't appear to have
any effect. We've seen lots of people asking this question, but
haven't found anyone answering it yet.


Thanks in advance





Peter
 
C

Champika Nirosh

Ar u using "Microsoft.ApplicationBlocks.Data" to access your database.. or
you use SQLHelper directly

As I said before you are missing some thing here.. You have to create a
SqlConnection by reading the values from the config file and assign it to
the SqlCommand so that it will use it when want to connect to the database..

just like below

// Associate the connection with the command
command.Connection = connection;

// Set the command text (stored procedure name or SQL statement)
command.CommandText = commandText;

// If you expect to role back the operation
command.Transaction = transaction;

// Set the command type
command.CommandType = commandType;

// Add parameters that need to pass in to the SP
command.Parameters.Add(parameters);

Then some thing like this would fill data to the dataset

// Create the DataAdapter & DataSet
using( SqlDataAdapter dataAdapter = new SqlDataAdapter(command) )
{

// Add the table mappings specified by the user
if (tableNames != null && tableNames.Length > 0)
{
string tableName = "Table";
for (int index=0; index < tableNames.Length; index++)
{
if( tableNames[index] == null || tableNames[index].Length == 0 ) throw
new ArgumentException( "The tableNames parameter must contain a list of
tables, a value was provided as null or empty string.", "tableNames" );
dataAdapter.TableMappings.Add(tableName, tableNames[index]);
tableName = "Table" + (index + 1).ToString();
}
}

// Fill the DataSet using default values for DataTable names, etc
dataAdapter.Fill(dataSet);

// Detach the SqlParameters from the command object, so they can be used
again
command.Parameters.Clear();
}


I am just writing this just to give you some idea but please do not directly
use them unless you refer to a good online resource about dataset

I don't think that this reply can contain all what you need to know about
dataset/ database.. little bit of googling will find you a resource on this
topic

Nirosh.

Peter Bradley said:
Sorry to follow up on my own post, but a little light may have just lit
up.

The table adapter created with the typed dataset has a Connection
property. If I set that, I might get somewhere. It's too late now,
tonight. I'll try it out in the morning and let the list know how I get
on, in case it helps someone else.



Cheers





Peter



Peter Bradley said:
OK. Here's what I tried.

The hard-coded values are pointing to our development database. So I
created the new table in our live database and created the stored
procedure there as well.

Then I altered the dll.config file that VS2005 puts into the same folder
as the executable to point to the live database, and ran the client.

The data is still returned from the development database.

Can you tell me what I'm doing wrong?


Peter

Peter Bradley said:
OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're
talking about another config file, how is it accessed in code and how is
it passed to the DataSet?

I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error
was generated and the data was retrieved from the development database
(as in the hard-coded strings).


Peter

To my understanding that value is *only* use for its internal stuff
such as seemlessly synchup with the database.. but not known that it is
used for anything once you deply the solution..I have develop many app
that has auto generated typed dataset and deployed them in many
different env and never bother this value.. I always taken the
connection string via the config file and use it in the dataaccess
layer to communicate with the database..

Nirosh.

If it was just for its internal use, I wouldn't be bothered. I've
tried it out, and there is no way of changing that setting via a
configuration file once the dll has been deployed (and put in the GAC
in our case) that has worked for me. If you can suggest a way, I'd be
very grateful.


Peter

So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Just in case anyone else has any doubts, here's the generated xsd
file (slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.atablename"
DbObjectType="Table" FillMethodModifier="Public"
FillMethodName="Fill" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetData"
GeneratorSourceName="Fill" GetMethodModifier="Public"
GetMethodName="GetData" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename] WHERE
(([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox
= @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group,
server FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET
[mailbox] = @mailbox, [storage_group] = @storage_group, [server] =
@server WHERE (([mailbox] = @Original_mailbox) AND ([storage_group]
= @Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE (mailbox
= @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox" DataSetColumn="mailbox"
/>
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server"
/>
</Mappings>
<Sources>
<DbSource ConnectionRef="aservernamedevConnectionString
(Settings)" DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">

<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True"
AutogeneratedName="" DataSourceName="" DbType="Int32"
Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10"
ProviderType="Int" Scale="0" Size="4"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the
question.


Peter

I am pretty sure that you are doing some thing wrong here.. can you
just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select the
optipon of autocreating the DAL then yes it does add a hardcoded
connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire data
access layer - which we code ourselves and which uses many typed
datasets. At least that was the case until now. If typed
datasets now have the connection string hard coded into them,
we'll definitely not be using them any more - for security
reasons apart from anything else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to
create/ edit the dataset again.

In my view point the automatically generated code is very good
if you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own
data access layer, indeed you may have some assistance from the
Data access Applcation Blocks or enterprise library. There you
will get that chance of developing a flexible dataaccess layer..
I am telling this with my experience and if you go with the auto
geneated code you will at times drive in to bottleneck of your
code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts
on configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's
new DataSet designer, but with the ability to configure the
connection string via a config file? The designer seems to
hard-code the connection string into the dataset itself, which
just can't be right.

The typed DataSets created by VS2005 comes with a dll.config
file that looks as though it's trying to do something like
that, and which is put with the executable at compile time, but
altering the connection string in there doesn't appear to have
any effect. We've seen lots of people asking this question, but
haven't found anyone answering it yet.


Thanks in advance





Peter
 
P

Peter Bradley

No. The only generated code we're using is the code generated for the
TypedDataSet, using VS2005 new DataSet designer.

When you create a typed dataset in this way, the connection you used in the
designer is hard-coded as the default connection. You *do not* need to
create a connection yourself.

However, now that I've noticed there's a Connection property on the table
adapter the designer creates, I think I should be able to set that: and that
is what I'll be trying out this morning. If that is correct, you don't
assign the connection as you describe. That's what I would do with a
non-typed DataSet.

Cheers


Peter

Champika Nirosh said:
Ar u using "Microsoft.ApplicationBlocks.Data" to access your database.. or
you use SQLHelper directly

As I said before you are missing some thing here.. You have to create a
SqlConnection by reading the values from the config file and assign it to
the SqlCommand so that it will use it when want to connect to the
database..

just like below

// Associate the connection with the command
command.Connection = connection;

// Set the command text (stored procedure name or SQL
statement)
command.CommandText = commandText;

// If you expect to role back the operation
command.Transaction = transaction;

// Set the command type
command.CommandType = commandType;

// Add parameters that need to pass in to the SP
command.Parameters.Add(parameters);

Then some thing like this would fill data to the dataset

// Create the DataAdapter & DataSet
using( SqlDataAdapter dataAdapter = new SqlDataAdapter(command) )
{

// Add the table mappings specified by the user
if (tableNames != null && tableNames.Length > 0)
{
string tableName = "Table";
for (int index=0; index < tableNames.Length; index++)
{
if( tableNames[index] == null || tableNames[index].Length == 0 )
throw new ArgumentException( "The tableNames parameter must contain a list
of tables, a value was provided as null or empty string.", "tableNames" );
dataAdapter.TableMappings.Add(tableName, tableNames[index]);
tableName = "Table" + (index + 1).ToString();
}
}

// Fill the DataSet using default values for DataTable names, etc
dataAdapter.Fill(dataSet);

// Detach the SqlParameters from the command object, so they can be
used again
command.Parameters.Clear();
}


I am just writing this just to give you some idea but please do not
directly use them unless you refer to a good online resource about dataset

I don't think that this reply can contain all what you need to know about
dataset/ database.. little bit of googling will find you a resource on
this topic

Nirosh.

Peter Bradley said:
Sorry to follow up on my own post, but a little light may have just lit
up.

The table adapter created with the typed dataset has a Connection
property. If I set that, I might get somewhere. It's too late now,
tonight. I'll try it out in the morning and let the list know how I get
on, in case it helps someone else.



Cheers





Peter



Peter Bradley said:
OK. Here's what I tried.

The hard-coded values are pointing to our development database. So I
created the new table in our live database and created the stored
procedure there as well.

Then I altered the dll.config file that VS2005 puts into the same folder
as the executable to point to the live database, and ran the client.

The data is still returned from the development database.

Can you tell me what I'm doing wrong?


Peter

OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're
talking about another config file, how is it accessed in code and how
is it passed to the DataSet?

I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error
was generated and the data was retrieved from the development database
(as in the hard-coded strings).


Peter

To my understanding that value is *only* use for its internal stuff
such as seemlessly synchup with the database.. but not known that it
is used for anything once you deply the solution..I have develop many
app that has auto generated typed dataset and deployed them in many
different env and never bother this value.. I always taken the
connection string via the config file and use it in the dataaccess
layer to communicate with the database..

Nirosh.

If it was just for its internal use, I wouldn't be bothered. I've
tried it out, and there is no way of changing that setting via a
configuration file once the dll has been deployed (and put in the GAC
in our case) that has worked for me. If you can suggest a way, I'd
be very grateful.


Peter

So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?

Nirosh.

Just in case anyone else has any doubts, here's the generated xsd
file (slightly anonymised):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString
(Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource
ConnectionRef="aservernamedevConnectionString (Settings)"
DbObjectName="aservernamedev.dbo.atablename" DbObjectType="Table"
FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData"
QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename]
WHERE (([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE
(mailbox = @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group,
server FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET
[mailbox] = @mailbox, [storage_group] = @storage_group, [server] =
@server WHERE (([mailbox] = @Original_mailbox) AND ([storage_group]
= @Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE
(mailbox = @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox"
DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server"
/>
</Mappings>
<Sources>
<DbSource
ConnectionRef="aservernamedevConnectionString (Settings)"
DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">

<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True"
AutogeneratedName="" DataSourceName="" DbType="Int32"
Direction="ReturnValue" ParameterName="@RETURN_VALUE"
Precision="10" ProviderType="Int" Scale="0" Size="4"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>

Nirosh. That's what we've done. That's why I'm asking the
question.


Peter

I am pretty sure that you are doing some thing wrong here.. can
you just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select
the optipon of autocreating the DAL then yes it does add a
hardcoded connection string to the dataset..

Nirosh.

Thanks Nirosh, but I'm not sure I understood all that.

I'm only talking about a typed DataSet: not about the entire
data access layer - which we code ourselves and which uses many
typed datasets. At least that was the case until now. If typed
datasets now have the connection string hard coded into them,
we'll definitely not be using them any more - for security
reasons apart from anything else.


Peter

VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to
create/ edit the dataset again.

In my view point the automatically generated code is very good
if you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own
data access layer, indeed you may have some assistance from the
Data access Applcation Blocks or enterprise library. There you
will get that chance of developing a flexible dataaccess
layer.. I am telling this with my experience and if you go with
the auto geneated code you will at times drive in to bottleneck
of your code..

Nirosh.


Hi all,

This post is sort of tangentially related to my earlier posts
on configuration files for DLLs.

Does anyone know how to create typed DataSets using VS2005's
new DataSet designer, but with the ability to configure the
connection string via a config file? The designer seems to
hard-code the connection string into the dataset itself, which
just can't be right.

The typed DataSets created by VS2005 comes with a dll.config
file that looks as though it's trying to do something like
that, and which is put with the executable at compile time,
but altering the connection string in there doesn't appear to
have any effect. We've seen lots of people asking this
question, but haven't found anyone answering it yet.


Thanks in advance





Peter
 
P

Peter Bradley

Once again, sorry to follow up on my own post.

This is now SOLVED. Here is how it's done (or at least how we succeeded in
doing it):

* Create a typed DataSet using the new Data Set Designer in Visual Studio
* Set the following properties on the TableAdapter created by the designer
* Connection -> "none"
* This will automatically set the Connection Modifier property to
"Object reference not set"
* Modifier -> "public"
* Compile the Typed DataSet and store the dll and config file in some
suitable place

If you don't change the properties to something like the above, when you
compile the code that tries to set the Connection property, you'll get an
error saying that access permissions do not allow the property to be set.

In the project that uses the typed dataset, reference the typed dataset and
then do something like this:

public DataTable GetMailDetails()
{

ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSetTableAdapters.student_storeTableAdapter
itregda = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSetTableAdapters.student_storeTableAdapter();
itregda.Connection = new SqlConnection("<A CONNECTION STRING RETRIEVED
FROM A CONFIG FILE>");

ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSet.student_storeDataTable
itregdt = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSet().student_store;

try
{
itregdt = itregda.GetDataBy();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
return itregdt;
}


Thanks to everyone for their help and suggestions. I hope this solution
will be useful to someone.

(On another note, we're not happy with the way the designer hard codes a
connection string into the DLL it produces. One of the things we try to do
is to keep these things away from the code - for security reasons as much as
anything). But I'll worry about that some other day :)



Peter
 
C

Champika Nirosh

Great to hear that you solve it..

Nirosh.

Peter Bradley said:
Once again, sorry to follow up on my own post.

This is now SOLVED. Here is how it's done (or at least how we succeeded
in doing it):

* Create a typed DataSet using the new Data Set Designer in Visual Studio
* Set the following properties on the TableAdapter created by the
designer
* Connection -> "none"
* This will automatically set the Connection Modifier property to
"Object reference not set"
* Modifier -> "public"
* Compile the Typed DataSet and store the dll and config file in some
suitable place

If you don't change the properties to something like the above, when you
compile the code that tries to set the Connection property, you'll get an
error saying that access permissions do not allow the property to be set.

In the project that uses the typed dataset, reference the typed dataset
and then do something like this:

public DataTable GetMailDetails()
{


ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSetTableAdapters.student_storeTableAdapter
itregda = new

ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSetTableAdapters.student_storeTableAdapter();
itregda.Connection = new SqlConnection("<A CONNECTION STRING RETRIEVED
FROM A CONFIG FILE>");


ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSet.student_storeDataTable
itregdt = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTypedDataSet().student_store;

try
{
itregdt = itregda.GetDataBy();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
return itregdt;
}


Thanks to everyone for their help and suggestions. I hope this solution
will be useful to someone.

(On another note, we're not happy with the way the designer hard codes a
connection string into the DLL it produces. One of the things we try to
do is to keep these things away from the code - for security reasons as
much as anything). But I'll worry about that some other day :)



Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top