468,780 Members | 2,319 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

Typed DataSets in VS2005

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
Mar 29 '07 #1
21 2075
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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
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


Mar 29 '07 #2
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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
>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



Mar 29 '07 #3
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
>>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




Mar 29 '07 #4
Yes. That appears to be the case. There's tons (UK) of talk about it if
you google for it e.g.

http://www.theserverside.net/discuss...hread_id=37108

(scroll down to "Connection string pangs")
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:eg**************@TK2MSFTNGP06.phx.gbl...
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
>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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>>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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
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




Mar 29 '07 #5
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
>>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




Mar 29 '07 #6
Nirosh. That's what we've done. That's why I'm asking the question.
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
>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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>>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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
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




Mar 29 '07 #7
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Yes. That appears to be the case. There's tons (UK) of talk about it if
you google for it e.g.

http://www.theserverside.net/discuss...hread_id=37108

(scroll down to "Connection string pangs")
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:eg**************@TK2MSFTNGP06.phx.gbl...
>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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
>>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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
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
>
>




Mar 29 '07 #8
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="aservernamedevConnectionS tring"
ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly"
Name="aservernamedevConnectionString (Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDe tailsTypedDataSet.Properties.Settings.GlobalRefere nce.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAd apter" 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_roundro bin"
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="ItregMailDetailsTyped DataSet"
msprop:Generator_DataSetName="ItregMailDetailsType dDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDele ted"
msprop:Generator_RowChangedName="atablenameRowChan ged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowCha nging"
msprop:Generator_RowEvArgName="atablenameRowChange Event"
msprop:Generator_RowEvHandlerName="atablenameRowCh angeEventHandler"
msprop:Generator_TableClassName="atablenameDataTab le"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDel eting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailb ox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxCol umn">
<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="columnstora ge_group"
msprop:Generator_ColumnPropNameInRow="storage_grou p"
msprop:Generator_ColumnPropNameInTable="storage_gr oupColumn">
<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="columnserve r"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColu mn">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
Nirosh. That's what we've done. That's why I'm asking the question.
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>>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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
>>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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
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.
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
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
>
>




Mar 29 '07 #9
Thanks, Nirosh.

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

"Champika Nirosh" <te**@tc.comwrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Yes. That appears to be the case. There's tons (UK) of talk about it if
you google for it e.g.

http://www.theserverside.net/discuss...hread_id=37108

(scroll down to "Connection string pangs")
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:eg**************@TK2MSFTNGP06.phx.gbl...
>>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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
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.
>
>
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl.. .
>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
>>
>>
>
>




Mar 29 '07 #10
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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>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="aservernamedevConnection String"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailD etailsTypedDataSet.Properties.Settings.GlobalRefer ence.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableA dapter"
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_roundro bin"
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="ItregMailDetailsType dDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTyp edDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDel eted"
msprop:Generator_RowChangedName="atablenameRowCha nged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowCh anging"
msprop:Generator_RowEvArgName="atablenameRowChang eEvent"
msprop:Generator_RowEvHandlerName="atablenameRowC hangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTa ble"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDe leting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmail box"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxCo lumn">
<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="columnstor age_group"
msprop:Generator_ColumnPropNameInRow="storage_gro up"
msprop:Generator_ColumnPropNameInTable="storage_g roupColumn">
<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="columnserv er"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverCol umn">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
>>Nirosh. That's what we've done. That's why I'm asking the question.
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
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
>
"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl.. .
>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.
>>
>>
>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>news:eL**************@TK2MSFTNGP02.phx.gbl. ..
>>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
>>>
>>>
>>
>>
>
>




Mar 29 '07 #11
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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="aservernamedevConnectionS tring"
ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly"
Name="aservernamedevConnectionString (Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDe tailsTypedDataSet.Properties.Settings.GlobalRefere nce.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAd apter" 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_roundro bin"
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="ItregMailDetailsTyped DataSet"
msprop:Generator_DataSetName="ItregMailDetailsType dDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDele ted"
msprop:Generator_RowChangedName="atablenameRowChan ged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowCha nging"
msprop:Generator_RowEvArgName="atablenameRowChange Event"
msprop:Generator_RowEvHandlerName="atablenameRowCh angeEventHandler"
msprop:Generator_TableClassName="atablenameDataTab le"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDel eting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailb ox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxCol umn">
<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="columnstora ge_group"
msprop:Generator_ColumnPropNameInRow="storage_grou p"
msprop:Generator_ColumnPropNameInTable="storage_gr oupColumn">
<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="columnserve r"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColu mn">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
>Nirosh. That's what we've done. That's why I'm asking the question.
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>>>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.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl...
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

"Champika Nirosh" <te**@tc.comwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
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.
>
>
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl.. .
>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
>>
>>
>
>




Mar 29 '07 #12
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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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="aservernamedevConnectio nString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMail DetailsTypedDataSet.Properties.Settings.GlobalRefe rence.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTable Adapter"
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_roundro bin"
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="ItregMailDetailsTyp edDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTy pedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDe leted"
msprop:Generator_RowChangedName="atablenameRowCh anged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowC hanging"
msprop:Generator_RowEvArgName="atablenameRowChan geEvent"
msprop:Generator_RowEvHandlerName="atablenameRow ChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataT able"
msprop:Generator_TableVarName="tableatablename "
msprop:Generator_RowDeletingName="atablenameRowD eleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmai lbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxC olumn">
<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="columnsto rage_group"
msprop:Generator_ColumnPropNameInRow="storage_gr oup"
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="columnser ver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverCo lumn">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
Nirosh. That's what we've done. That's why I'm asking the question.
Peter

"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
>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.
>
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uH**************@TK2MSFTNGP02.phx.gbl.. .
>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
>>
>"Champika Nirosh" <te**@tc.comwrote in message
>news:eL**************@TK2MSFTNGP04.phx.gbl. ..
>>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.
>>>
>>>
>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>news:eL**************@TK2MSFTNGP02.phx.gbl.. .
>>>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
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 29 '07 #13
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" <te**@tc.comwrote in message
news:OO**************@TK2MSFTNGP03.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
>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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
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="aservernamedevConnecti onString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMai lDetailsTypedDataSet.Properties.Settings.GlobalRef erence.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTabl eAdapter"
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_roundro bin"
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="ItregMailDetailsTy pedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsT ypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowD eleted"
msprop:Generator_RowChangedName="atablenameRowC hanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRow Changing"
msprop:Generator_RowEvArgName="atablenameRowCha ngeEvent"
msprop:Generator_RowEvHandlerName="atablenameRo wChangeEventHandler"
msprop:Generator_TableClassName="atablenameData Table"
msprop:Generator_TableVarName="tableatablenam e"
msprop:Generator_RowDeletingName="atablenameRow Deleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnma ilbox"
msprop:Generator_ColumnPropNameInRow="mailbox "
msprop:Generator_ColumnPropNameInTable="mailbox Column">
<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_grou p"
msprop:Generator_ColumnVarNameInTable="columnst orage_group"
msprop:Generator_ColumnPropNameInRow="storage_g roup"
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="columnse rver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverC olumn">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl...
Nirosh. That's what we've done. That's why I'm asking the question.
>
>
Peter
>
"Champika Nirosh" <te**@tc.comwrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl.. .
>>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.
>>
>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>news:uH**************@TK2MSFTNGP02.phx.gbl. ..
>>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
>>>
>>"Champika Nirosh" <te**@tc.comwrote in message
>>news:eL**************@TK2MSFTNGP04.phx.gbl.. .
>>>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.
>>>>
>>>>
>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>news:eL**************@TK2MSFTNGP02.phx.gbl. ..
>>>>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
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 29 '07 #14
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" <pb******@uwic.ac.ukwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
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" <te**@tc.comwrote in message
news:OO**************@TK2MSFTNGP03.phx.gbl...
>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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
>>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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
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="aservernamedevConnect ionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMa ilDetailsTypedDataSet.Properties.Settings.GlobalRe ference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTab leAdapter"
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_roundro bin"
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="ItregMailDetailsT ypedDataSet"
msprop:Generator_DataSetName="ItregMailDetails TypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRow Deleted"
msprop:Generator_RowChangedName="atablenameRow Changed"
msprop:Generator_RowClassName="atablenameRow "
msprop:Generator_RowChangingName="atablenameRo wChanging"
msprop:Generator_RowEvArgName="atablenameRowCh angeEvent"
msprop:Generator_RowEvHandlerName="atablenameR owChangeEventHandler"
msprop:Generator_TableClassName="atablenameDat aTable"
msprop:Generator_TableVarName="tableatablename "
msprop:Generator_RowDeletingName="atablenameRo wDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnm ailbox"
msprop:Generator_ColumnPropNameInRow="mailbo x"
msprop:Generator_ColumnPropNameInTable="mailbo xColumn">
<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="columns torage_group"
msprop:Generator_ColumnPropNameInRow="storage_ group"
msprop:Generator_ColumnPropNameInTable="storag e_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="columns erver"
msprop:Generator_ColumnPropNameInRow="server "
msprop:Generator_ColumnPropNameInTable="server Column">
<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" <pb******@uwic.ac.ukwrote in message
news:eP**************@TK2MSFTNGP02.phx.gbl.. .
>Nirosh. That's what we've done. That's why I'm asking the question.
>>
>>
>Peter
>>
>"Champika Nirosh" <te**@tc.comwrote in message
>news:ub**************@TK2MSFTNGP02.phx.gbl. ..
>>>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.
>>>
>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>news:uH**************@TK2MSFTNGP02.phx.gbl.. .
>>>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
>>>>
>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>news:eL**************@TK2MSFTNGP04.phx.gbl. ..
>>>>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.
>>>>>
>>>>>
>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>news:eL**************@TK2MSFTNGP02.phx.gbl ...
>>>>>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
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 29 '07 #15
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" <pb******@uwic.ac.ukwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>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" <te**@tc.comwrote in message
news:OO**************@TK2MSFTNGP03.phx.gbl...
>>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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>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="aservernamedevConnec tionString"
>ConnectionStringObject="" IsAppSettingsProperty="True"
>Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
>ParameterPrefix="@"
>PropertyReference="ApplicationSettings.ItregM ailDetailsTypedDataSet.Properties.Settings.GlobalR eference.Default.aservernamedevConnectionString"
>Provider="System.Data.SqlClient">
> </Connection>
> </Connections>
> <Tables>
> <TableAdapter BaseClass="System.ComponentModel.Component"
>DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
>DataAccessorName="atablenameTableAdapter"
>GeneratorDataComponentClassName="atablenameTa bleAdapter"
>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_roundro bin"
>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="ItregMailDetails TypedDataSet"
>msprop:Generator_DataSetName="ItregMailDetail sTypedDataSet">
> <xs:complexType>
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element name="atablename"
>msprop:Generator_UserTableName="atablename"
>msprop:Generator_RowDeletedName="atablenameRo wDeleted"
>msprop:Generator_RowChangedName="atablenameRo wChanged"
>msprop:Generator_RowClassName="atablenameRo w"
>msprop:Generator_RowChangingName="atablenameR owChanging"
>msprop:Generator_RowEvArgName="atablenameRowC hangeEvent"
>msprop:Generator_RowEvHandlerName="atablename RowChangeEventHandler"
>msprop:Generator_TableClassName="atablenameDa taTable"
>msprop:Generator_TableVarName="tableatablenam e"
>msprop:Generator_RowDeletingName="atablenameR owDeleting"
>msprop:Generator_TablePropName="atablename" >
> <xs:complexType>
> <xs:sequence>
> <xs:element name="mailbox"
>msprop:Generator_UserColumnName="mailbox"
>msprop:Generator_ColumnVarNameInTable="column mailbox"
>msprop:Generator_ColumnPropNameInRow="mailbox "
>msprop:Generator_ColumnPropNameInTable="mailb oxColumn">
> <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_grou p"
>msprop:Generator_ColumnVarNameInTable="column storage_group"
>msprop:Generator_ColumnPropNameInRow="storage _group"
>msprop:Generator_ColumnPropNameInTable="stora ge_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="column server"
>msprop:Generator_ColumnPropNameInRow="serve r"
>msprop:Generator_ColumnPropNameInTable="serve rColumn">
> <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" <pb******@uwic.ac.ukwrote in message
>news:eP**************@TK2MSFTNGP02.phx.gbl. ..
>>Nirosh. That's what we've done. That's why I'm asking the
>>question.
>>>
>>>
>>Peter
>>>
>>"Champika Nirosh" <te**@tc.comwrote in message
>>news:ub**************@TK2MSFTNGP02.phx.gbl.. .
>>>>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.
>>>>
>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>news:uH**************@TK2MSFTNGP02.phx.gbl. ..
>>>>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
>>>>>
>>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>>news:eL**************@TK2MSFTNGP04.phx.gbl ...
>>>>>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.
>>>>>>
>>>>>>
>>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>>news:eL**************@TK2MSFTNGP02.phx.gb l...
>>>>>>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
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 29 '07 #16
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...
>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" <pb******@uwic.ac.ukwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
>>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" <te**@tc.comwrote in message
news:OO**************@TK2MSFTNGP03.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
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" <te**@tc.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>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" <pb******@uwic.ac.ukwrote in message
>news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>>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="QueriesTableAdapte r" Modifier="AutoLayout,
>>AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
>>xmlns="urn:schemas-microsoft-com:xml-msdatasource">
>> <Connections>
>> <Connection AppSettingsObjectName="Settings"
>>AppSettingsPropertyName="aservernamedevConne ctionString"
>>ConnectionStringObject="" IsAppSettingsProperty="True"
>>Modifier="Assembly" Name="aservernamedevConnectionString (Settings)"
>>ParameterPrefix="@"
>>PropertyReference="ApplicationSettings.Itreg MailDetailsTypedDataSet.Properties.Settings.Global Reference.Default.aservernamedevConnectionString"
>>Provider="System.Data.SqlClient">
>> </Connection>
>> </Connections>
>> <Tables>
>> <TableAdapter BaseClass="System.ComponentModel.Component"
>>DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
>>DataAccessorName="atablenameTableAdapter"
>>GeneratorDataComponentClassName="atablenameT ableAdapter"
>>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_roundro bin"
>>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="ItregMailDetail sTypedDataSet"
>>msprop:Generator_DataSetName="ItregMailDetai lsTypedDataSet">
>> <xs:complexType>
>> <xs:choice minOccurs="0" maxOccurs="unbounded">
>> <xs:element name="atablename"
>>msprop:Generator_UserTableName="atablename "
>>msprop:Generator_RowDeletedName="atablenameR owDeleted"
>>msprop:Generator_RowChangedName="atablenameR owChanged"
>>msprop:Generator_RowClassName="atablenameRow "
>>msprop:Generator_RowChangingName="atablename RowChanging"
>>msprop:Generator_RowEvArgName="atablenameRow ChangeEvent"
>>msprop:Generator_RowEvHandlerName="atablenam eRowChangeEventHandler"
>>msprop:Generator_TableClassName="atablenameD ataTable"
>>msprop:Generator_TableVarName="tableatablena me"
>>msprop:Generator_RowDeletingName="atablename RowDeleting"
>>msprop:Generator_TablePropName="atablename ">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="mailbox"
>>msprop:Generator_UserColumnName="mailbox"
>>msprop:Generator_ColumnVarNameInTable="colum nmailbox"
>>msprop:Generator_ColumnPropNameInRow="mailbo x"
>>msprop:Generator_ColumnPropNameInTable="mail boxColumn">
>> <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_gro up"
>>msprop:Generator_ColumnVarNameInTable="colum nstorage_group"
>>msprop:Generator_ColumnPropNameInRow="storag e_group"
>>msprop:Generator_ColumnPropNameInTable="stor age_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="colum nserver"
>>msprop:Generator_ColumnPropNameInRow="server "
>>msprop:Generator_ColumnPropNameInTable="serv erColumn">
>> <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" <pb******@uwic.ac.ukwrote in message
>>news:eP**************@TK2MSFTNGP02.phx.gbl.. .
>>>Nirosh. That's what we've done. That's why I'm asking the
>>>question.
>>>>
>>>>
>>>Peter
>>>>
>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>news:ub**************@TK2MSFTNGP02.phx.gbl. ..
>>>>>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.
>>>>>
>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>news:uH**************@TK2MSFTNGP02.phx.gbl ...
>>>>>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
>>>>>>
>>>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>>>news:eL**************@TK2MSFTNGP04.phx.gb l...
>>>>>>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.
>>>>>>>
>>>>>>>
>>>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>>>news:eL**************@TK2MSFTNGP02.phx.g bl...
>>>>>>>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
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 30 '07 #17
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" <te**@tc.comwrote in message
news:uJ**************@TK2MSFTNGP04.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>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" <pb******@uwic.ac.ukwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...
>>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" <pb******@uwic.ac.ukwrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...
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" <te**@tc.comwrote in message
news:OO**************@TK2MSFTNGP03.phx.gbl...
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" <pb******@uwic.ac.ukwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl.. .
>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" <te**@tc.comwrote in message
>news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>>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" <pb******@uwic.ac.ukwrote in message
>>news:%2****************@TK2MSFTNGP02.phx.gbl ...
>>>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="aservernamedevConn ectionString"
>>>ConnectionStringObject="" IsAppSettingsProperty="True"
>>>Modifier="Assembly" Name="aservernamedevConnectionString
>>>(Settings)" ParameterPrefix="@"
>>>PropertyReference="ApplicationSettings.Itre gMailDetailsTypedDataSet.Properties.Settings.Globa lReference.Default.aservernamedevConnectionString"
>>>Provider="System.Data.SqlClient">
>>> </Connection>
>>> </Connections>
>>> <Tables>
>>> <TableAdapter BaseClass="System.ComponentModel.Component"
>>>DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
>>>DataAccessorName="atablenameTableAdapter"
>>>GeneratorDataComponentClassName="atablename TableAdapter"
>>>Name="atablename" UserDataComponentName="atablenameTableAdapter">
>>> <MainSource>
>>> <DbSource
>>>ConnectionRef="aservernamedevConnectionStri ng (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="aservernamedevConnectionStri ng (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="ItregMailDetai lsTypedDataSet"
>>>msprop:Generator_DataSetName="ItregMailDeta ilsTypedDataSet">
>>> <xs:complexType>
>>> <xs:choice minOccurs="0" maxOccurs="unbounded">
>>> <xs:element name="atablename"
>>>msprop:Generator_UserTableName="atablenam e"
>>>msprop:Generator_RowDeletedName="atablename RowDeleted"
>>>msprop:Generator_RowChangedName="atablename RowChanged"
>>>msprop:Generator_RowClassName="atablenameRo w"
>>>msprop:Generator_RowChangingName="atablenam eRowChanging"
>>>msprop:Generator_RowEvArgName="atablenameRo wChangeEvent"
>>>msprop:Generator_RowEvHandlerName="atablena meRowChangeEventHandler"
>>>msprop:Generator_TableClassName="atablename DataTable"
>>>msprop:Generator_TableVarName="tableatablen ame"
>>>msprop:Generator_RowDeletingName="atablenam eRowDeleting"
>>>msprop:Generator_TablePropName="atablename" >
>>> <xs:complexType>
>>> <xs:sequence>
>>> <xs:element name="mailbox"
>>>msprop:Generator_UserColumnName="mailbox"
>>>msprop:Generator_ColumnVarNameInTable="colu mnmailbox"
>>>msprop:Generator_ColumnPropNameInRow="mailb ox"
>>>msprop:Generator_ColumnPropNameInTable="mai lboxColumn">
>>> <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_gr oup"
>>>msprop:Generator_ColumnVarNameInTable="colu mnstorage_group"
>>>msprop:Generator_ColumnPropNameInRow="stora ge_group"
>>>msprop:Generator_ColumnPropNameInTable="sto rage_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="colu mnserver"
>>>msprop:Generator_ColumnPropNameInRow="serve r"
>>>msprop:Generator_ColumnPropNameInTable="ser verColumn">
>>> <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" <pb******@uwic.ac.ukwrote in message
>>>news:eP**************@TK2MSFTNGP02.phx.gbl. ..
>>>>Nirosh. That's what we've done. That's why I'm asking the
>>>>question.
>>>>>
>>>>>
>>>>Peter
>>>>>
>>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>>news:ub**************@TK2MSFTNGP02.phx.gbl ...
>>>>>>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.
>>>>>>
>>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>>news:uH**************@TK2MSFTNGP02.phx.gb l...
>>>>>>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
>>>>>>>
>>>>>>"Champika Nirosh" <te**@tc.comwrote in message
>>>>>>news:eL**************@TK2MSFTNGP04.phx.g bl...
>>>>>>>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.
>>>>>>>>
>>>>>>>>
>>>>>>>"Peter Bradley" <pb******@uwic.ac.ukwrote in message
>>>>>>>news:eL**************@TK2MSFTNGP02.phx. gbl...
>>>>>>>>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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Mar 30 '07 #18
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.ItregMailDetailsTyped DataSetTableAdapters.student_storeTableAdapter
itregda = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSetTableAdapters.student_storeTableAdapter();
itregda.Connection = new SqlConnection("<A CONNECTION STRING RETRIEVED
FROM A CONFIG FILE>");

ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSet.student_storeDataTable
itregdt = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSet().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

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
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

Mar 30 '07 #19
Great to hear that you solve it..

Nirosh.

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:O7**************@TK2MSFTNGP02.phx.gbl...
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.ItregMailDetailsTyped DataSetTableAdapters.student_storeTableAdapter
itregda = new

ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSetTableAdapters.student_storeTableAdapter();
itregda.Connection = new SqlConnection("<A CONNECTION STRING RETRIEVED
FROM A CONFIG FILE>");
ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSet.student_storeDataTable
itregdt = new
ItregMailDetailsTypedDataSet.ItregMailDetailsTyped DataSet().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

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
>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


Mar 30 '07 #20
"Champika Nirosh" <te**@tc.comwrote in message
news:el*************@TK2MSFTNGP06.phx.gbl...
Great to hear that you solve it..

Nirosh.
Thanks Nirosh, and thank you for sticking with it.

One interesting thing about the new Typed DataSets is that a dll.config file
is produced (as I have mentioned) when the assembly is compiled. If the
contents of that file are copied into the calling executable's App.config
file, connection strings can be accessed like this:
string cs =
ConfigurationManager.ConnectionStrings["ItregMailDetailsTypedDataSet.Properties.Settings. cimisdevConnectionString"].ConnectionString;
Mar 30 '07 #21
"Champika Nirosh" <te**@tc.comwrote in message
news:el*************@TK2MSFTNGP06.phx.gbl...
Great to hear that you solve it..

Nirosh.
Thanks Nirosh, and thank you for sticking with it.

One interesting thing about the new Typed DataSets is that a dll.config file
is produced (as I have mentioned) when the assembly is compiled.

The contents of this file look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add
name="ItregMailDetailsTypedDataSet.Properties.Sett ings.cimisdevConnectionString"
connectionString="Data Source=adatabaseserver;Initial
Catalog=adatabase;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

If these contents are copied into the calling executable's App.config file,
connection strings can be accessed like this:

string cs =
ConfigurationManager.ConnectionStrings["ItregMailDetailsTypedDataSet.Properties.Settings. cimisdevConnectionString"].ConnectionString;

So you can set the TableAdapter's Connection property like this:

itregda.Connection = new SqlConnection(cs);

The only thing we remain unhappy about is that the Typed DataSets produced
by VS2005 appear to contain hard-coded connection details. We're going to
look at what's exposed in a dissassembler, and decide how safe/unsafe we
think it is, bearing in mind that the client needs to have the Typed DataSet
assembly in order to understand what it's getting back from its calls to the
Data Layer.

Cheers
Peter
Mar 30 '07 #22

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by alex | last post: by
4 posts views Thread by Ronald S. Cook | last post: by
13 posts views Thread by Rotsey | last post: by
reply views Thread by Ben | last post: by
12 posts views Thread by BillE | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.