OK. Here's what I tried.
The hard-coded values are pointing to our development database. So I
created the new table in our live database and created the stored
procedure there as well.
Then I altered the dll.config file that VS2005 puts into the same folder
as the executable to point to the live database, and ran the client.
The data is still returned from the development database.
Can you tell me what I'm doing wrong?
Peter
OK. So what you're saying is that I need to change the value in, "the
config file". Would this be the dll.config that comes with the typed
dataset? Or are you talking about another config file? If you're
talking about another config file, how is it accessed in code and how
is it passed to the DataSet?
I should say that I changed the dll.config to point to a non-existent
database, then ran the executable expecting to get an error. No error
was generated and the data was retrieved from the development database
(as in the hard-coded strings).
Peter
To my understanding that value is *only* use for its internal stuff
such as seemlessly synchup with the database.. but not known that it
is used for anything once you deply the solution..I have develop many
app that has auto generated typed dataset and deployed them in many
different env and never bother this value.. I always taken the
connection string via the config file and use it in the dataaccess
layer to communicate with the database..
Nirosh.
If it was just for its internal use, I wouldn't be bothered. I've
tried it out, and there is no way of changing that setting via a
configuration file once the dll has been deployed (and put in the GAC
in our case) that has worked for me. If you can suggest a way, I'd
be very grateful.
Peter
So now let's come back again so the designer keep it in the
setting.Designer.cs for its internal use.. so what bother you there?
Nirosh.
Just in case anyone else has any doubts, here's the generated xsd
file (slightly anonymised):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItregMailDetailsTypedDataSet"
targetNamespace="
http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:mstns="
http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns="
http://tempuri.org/ItregMailDetailsTypedDataSet.xsd"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0"
FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout,
AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema"
xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings"
AppSettingsPropertyName="aservernamedevConnectionString"
ConnectionStringObject="" IsAppSettingsProperty="True"
Modifier="Assembly" Name="aservernamedevConnectionString
(Settings)" ParameterPrefix="@"
PropertyReference="ApplicationSettings.ItregMailDetailsTypedDataSet.Properties.Settings.GlobalReference.Default.aservernamedevConnectionString"
Provider="System.Data.SqlClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component"
DataAccessorModifier="AutoLayout, AnsiClass, Class, Public"
DataAccessorName="atablenameTableAdapter"
GeneratorDataComponentClassName="atablenameTableAdapter"
Name="atablename" UserDataComponentName="atablenameTableAdapter">
<MainSource>
<DbSource
ConnectionRef="aservernamedevConnectionString (Settings)"
DbObjectName="aservernamedev.dbo.atablename" DbObjectType="Table"
FillMethodModifier="Public" FillMethodName="Fill"
GenerateMethods="Both" GenerateShortCommands="True"
GeneratorGetMethodName="GetData" GeneratorSourceName="Fill"
GetMethodModifier="Public" GetMethodName="GetData"
QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetData"
UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[atablename]
WHERE (([mailbox] = @Original_mailbox) AND ([storage_group] =
@Original_storage_group) AND ([server] =
@Original_server))</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[atablename]
([mailbox], [storage_group], [server]) VALUES (@mailbox,
@storage_group, @server);
SELECT mailbox, storage_group, server FROM atablename WHERE
(mailbox = @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>SELECT mailbox, storage_group,
server FROM dbo.atablename</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text"
ModifiedByUser="False">
<CommandText>UPDATE [dbo].[atablename] SET
[mailbox] = @mailbox, [storage_group] = @storage_group, [server] =
@server WHERE (([mailbox] = @Original_mailbox) AND ([storage_group]
= @Original_storage_group) AND ([server] = @Original_server));
SELECT mailbox, storage_group, server FROM atablename WHERE
(mailbox = @mailbox)</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@storage_group" Precision="0"
ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_mailbox" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="mailbox"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_storage_group"
Precision="0" ProviderType="VarChar" Scale="0" Size="0"
SourceColumn="storage_group" SourceColumnNullMapping="False"
SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False"
AutogeneratedName="" DataSourceName="" DbType="AnsiString"
Direction="Input" ParameterName="@Original_server" Precision="0"
ProviderType="VarChar" Scale="0" Size="0" SourceColumn="server"
SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="mailbox"
DataSetColumn="mailbox" />
<Mapping SourceColumn="storage_group"
DataSetColumn="storage_group" />
<Mapping SourceColumn="server" DataSetColumn="server"
/>
</Mappings>
<Sources>
<DbSource
ConnectionRef="aservernamedevConnectionString (Settings)"
DbObjectName="aservernamedev.dbo.usp_itreg_roundrobin"
DbObjectType="StoredProcedure" FillMethodModifier="Public"
FillMethodName="FillBy" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetDataBy"
GeneratorSourceName="FillBy" GetMethodModifier="Public"
GetMethodName="GetDataBy" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetDataBy"
UserSourceName="FillBy">
<SelectCommand>
<DbCommand CommandType="StoredProcedure"
ModifiedByUser="False">
<CommandText>dbo.usp_itreg_roundrobin</CommandText>
<Parameters>
<Parameter AllowDbNull="True"
AutogeneratedName="" DataSourceName="" DbType="Int32"
Direction="ReturnValue" ParameterName="@RETURN_VALUE"
Precision="10" ProviderType="Int" Scale="0" Size="4"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="ItregMailDetailsTypedDataSet"
msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
msprop:Generator_UserDSName="ItregMailDetailsTypedDataSet"
msprop:Generator_DataSetName="ItregMailDetailsTypedDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="atablename"
msprop:Generator_UserTableName="atablename"
msprop:Generator_RowDeletedName="atablenameRowDeleted"
msprop:Generator_RowChangedName="atablenameRowChanged"
msprop:Generator_RowClassName="atablenameRow"
msprop:Generator_RowChangingName="atablenameRowChanging"
msprop:Generator_RowEvArgName="atablenameRowChangeEvent"
msprop:Generator_RowEvHandlerName="atablenameRowChangeEventHandler"
msprop:Generator_TableClassName="atablenameDataTable"
msprop:Generator_TableVarName="tableatablename"
msprop:Generator_RowDeletingName="atablenameRowDeleting"
msprop:Generator_TablePropName="atablename">
<xs:complexType>
<xs:sequence>
<xs:element name="mailbox"
msprop:Generator_UserColumnName="mailbox"
msprop:Generator_ColumnVarNameInTable="columnmailbox"
msprop:Generator_ColumnPropNameInRow="mailbox"
msprop:Generator_ColumnPropNameInTable="mailboxColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="storage_group"
msprop:Generator_UserColumnName="storage_group"
msprop:Generator_ColumnVarNameInTable="columnstorage_group"
msprop:Generator_ColumnPropNameInRow="storage_group"
msprop:Generator_ColumnPropNameInTable="storage_groupColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="server"
msprop:Generator_UserColumnName="server"
msprop:Generator_ColumnVarNameInTable="columnserver"
msprop:Generator_ColumnPropNameInRow="server"
msprop:Generator_ColumnPropNameInTable="serverColumn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:atablename" />
<xs:field xpath="mstns:mailbox" />
</xs:unique>
</xs:element>
</xs:schema>
Nirosh. That's what we've done. That's why I'm asking the
question.
Peter
I am pretty sure that you are doing some thing wrong here.. can
you just create a seperate type dataset and confirm that it add a
connection string too?? Why it need to have a connection string
hradcoded to create a typed dataset for you.. but it you select
the optipon of autocreating the DAL then yes it does add a
hardcoded connection string to the dataset..
Nirosh.
Thanks Nirosh, but I'm not sure I understood all that.
I'm only talking about a typed DataSet: not about the entire
data access layer - which we code ourselves and which uses many
typed datasets. At least that was the case until now. If typed
datasets now have the connection string hard coded into them,
we'll definitely not be using them any more - for security
reasons apart from anything else.
Peter
VSS 2005 support auto generating the dataaccess layer .. and in
that case you are free to change the code where it hardcode the
connection string so that it will read it from a config file
(obviously you have to change the code again if you have to
create/ edit the dataset again.
In my view point the automatically generated code is very good
if you are heading toward a quick concept demo or a working
prototype.. but if you are looking to develop a real extensible
large-scale system, then I rather advice you to have your own
data access layer, indeed you may have some assistance from the
Data access Applcation Blocks or enterprise library. There you
will get that chance of developing a flexible dataaccess
layer.. I am telling this with my experience and if you go with
the auto geneated code you will at times drive in to bottleneck
of your code..
Nirosh.
Hi all,
This post is sort of tangentially related to my earlier posts
on configuration files for DLLs.
Does anyone know how to create typed DataSets using VS2005's
new DataSet designer, but with the ability to configure the
connection string via a config file? The designer seems to
hard-code the connection string into the dataset itself, which
just can't be right.
The typed DataSets created by VS2005 comes with a dll.config
file that looks as though it's trying to do something like
that, and which is put with the executable at compile time,
but altering the connection string in there doesn't appear to
have any effect. We've seen lots of people asking this
question, but haven't found anyone answering it yet.
Thanks in advance
Peter