Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Wednesday, March 28, 2012

TableAdapters and web.config

I have a class library that contains a number of TableAdapters and I'm using
this from a web application. Is there a way of getting the TableAdapters to
use the connectionstrings defined in web.config.

From the MSDN documentation it seems like it's possible to override settings
with values in a config file for winform applications. Is the same possible
for web applications.

I have tried to add a connectionstring (under the connectionstring section)
in web.config with the same name as the name in the setting file. The
connectionstring in web.config points to a database that doesn't contain the
required schema. Since I'm not getting any errors and things are still
working, I assume it is still using the default connectionstring supplied at
designtime.Hi Kimbell,

Welcome to ASP.NET newsgroup.
Regarding on the configuration issue you mentioned when using TableAdapter
from class library in asp.net 2.0 project, I've also met this problem
before. Yes, as you has mentioned, when we has build the
DataSet/TableAdapter in class library project, the TableAdapter's
Connection /ConnectionString setting is persisted in the classlibrary
assembly's content so that when referenced in asp.net 2.0 project, it won't
use the web.config file's info (but still use the one persisted at
design-time in classlibrary project). Based on my research, as for the
Project Settings, the asp.net 2.0 seems has different support from winform
project. Currently one approach is manually modify the TableAdapter's
design-time generated code in the Classlibrary project. for example:

the TAbleAdapter's autogenerate code is as below, the "InitConnection"
function is just the one which supply connectionstring and constructing the
Connection instance for the TableAdapter

=============================
private void InitConnection()
{
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString =
DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
}

which retrieve the connection string through Project's Properties.Settings
collection. We can modify it to the following one:

======================

Object obj =
System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
ConnectionStringsSection css = obj as ConnectionStringsSection;
string connstr =
css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString = connstr;

=====================

so that it will retrieve the info from the final hosting application's
application config file (appconfig or web.config).

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security

-------
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXNckyfTDC6JTskQe231gX8p+7Y9A==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "=?Utf-8?B?Q2hyaXN0b3BoZXIgS2ltYmVsbA==?="
<c_kimbell@.newsgroup.nospam>
| Subject: TableAdapters and web.config
| Date: Mon, 10 Oct 2005 01:12:04 -0700
| Lines: 15
| Message-ID: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349611
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I have a class library that contains a number of TableAdapters and I'm
using
| this from a web application. Is there a way of getting the TableAdapters
to
| use the connectionstrings defined in web.config.
|
| From the MSDN documentation it seems like it's possible to override
settings
| with values in a config file for winform applications. Is the same
possible
| for web applications.
|
| I have tried to add a connectionstring (under the connectionstring
section)
| in web.config with the same name as the name in the setting file. The
| connectionstring in web.config points to a database that doesn't contain
the
| required schema. Since I'm not getting any errors and things are still
| working, I assume it is still using the default connectionstring supplied
at
| designtime.
|
|
So what you are recommending is to change the autogenerated code?
What about the following warning at the top of the file:

"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."

Particularly the statement about lost changes.

I think a better approach is to change the ConnectionModifier to public in
the designer; then set the connectionstring from code.

I was hoping for a more elegant solution since Microsoft has put some work
into this settings system. Maybe in the next version.

"Steven Cheng[MSFT]" wrote:

> Hi Kimbell,
> Welcome to ASP.NET newsgroup.
> Regarding on the configuration issue you mentioned when using TableAdapter
> from class library in asp.net 2.0 project, I've also met this problem
> before. Yes, as you has mentioned, when we has build the
> DataSet/TableAdapter in class library project, the TableAdapter's
> Connection /ConnectionString setting is persisted in the classlibrary
> assembly's content so that when referenced in asp.net 2.0 project, it won't
> use the web.config file's info (but still use the one persisted at
> design-time in classlibrary project). Based on my research, as for the
> Project Settings, the asp.net 2.0 seems has different support from winform
> project. Currently one approach is manually modify the TableAdapter's
> design-time generated code in the Classlibrary project. for example:
> the TAbleAdapter's autogenerate code is as below, the "InitConnection"
> function is just the one which supply connectionstring and constructing the
> Connection instance for the TableAdapter
> =============================
> private void InitConnection()
> {
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString =
> DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
> }
> which retrieve the connection string through Project's Properties.Settings
> collection. We can modify it to the following one:
> ======================
> Object obj =
> System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
> ConnectionStringsSection css = obj as ConnectionStringsSection;
> string connstr =
> css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString = connstr;
> =====================
> so that it will retrieve the info from the final hosting application's
> application config file (appconfig or web.config).
> Hope helps. Thanks,
> Steven Cheng
> Microsoft Online Support
Thanks for your response Kimbell,

Yes, the
========
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
========
you mentioned is really a potential problem with my workaround. And your
appoarch on changing the ConnectionModifer to public is OK for
programmatical accessing. However, in most cases of ASP.NET 2.0 web
application, we will use design-time ObjectDataSource control to reference
the TableAdpater, and this is done through IDE interactively no code is
involved. So in such scenario, we may need to predefined the connection's
initilization in TableAdapter's code.

Anyway, I really appreciate your advice on the configuration setttings ,
and since this is a new feature involved in 2.0, I think it'll be improved
in the sequential versions so as to ease the component, class library
developing and seamless integrated into
front end applications.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
-------
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXOO+CVs5sRlZYtRh+M2u+nQzNUBg==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "=?Utf-8?B?Q2hyaXN0b3BoZXIgS2ltYmVsbA==?="
<c_kimbell@.newsgroup.nospam>
| References: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
<o4v8pDhzFHA.3712@.TK2MSFTNGXA02.phx.gbl>
| Subject: RE: TableAdapters and web.config
| Date: Tue, 11 Oct 2005 01:15:01 -0700
| Lines: 68
| Message-ID: <EAC2EB76-0E98-4837-AD33-55A57F82A6EA@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349877
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So what you are recommending is to change the autogenerated code?
| What about the following warning at the top of the file:
|
| "Changes to this file may cause incorrect behavior and will be lost if
the
| code is regenerated."
|
| Particularly the statement about lost changes.
|
| I think a better approach is to change the ConnectionModifier to public
in
| the designer; then set the connectionstring from code.
|
| I was hoping for a more elegant solution since Microsoft has put some
work
| into this settings system. Maybe in the next version.
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Kimbell,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the configuration issue you mentioned when using
TableAdapter
| > from class library in asp.net 2.0 project, I've also met this problem
| > before. Yes, as you has mentioned, when we has build the
| > DataSet/TableAdapter in class library project, the TableAdapter's
| > Connection /ConnectionString setting is persisted in the classlibrary
| > assembly's content so that when referenced in asp.net 2.0 project, it
won't
| > use the web.config file's info (but still use the one persisted at
| > design-time in classlibrary project). Based on my research, as for the
| > Project Settings, the asp.net 2.0 seems has different support from
winform
| > project. Currently one approach is manually modify the TableAdapter's
| > design-time generated code in the Classlibrary project. for example:
| >
| > the TAbleAdapter's autogenerate code is as below, the "InitConnection"
| > function is just the one which supply connectionstring and constructing
the
| > Connection instance for the TableAdapter
| >
| > =============================
| > private void InitConnection()
| > {
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString =
| > DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
| > }
| >
| > which retrieve the connection string through Project's
Properties.Settings
| > collection. We can modify it to the following one:
| >
| > ======================
| >
| > Object obj =
| >
System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
| > ConnectionStringsSection css = obj as ConnectionStringsSection;
| > string connstr =
| > css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString = connstr;
| >
| > =====================
| >
| > so that it will retrieve the info from the final hosting application's
| > application config file (appconfig or web.config).
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
|
|

TableAdapters and web.config

I have a class library that contains a number of TableAdapters and I'm using
this from a web application. Is there a way of getting the TableAdapters to
use the connectionstrings defined in web.config.
From the MSDN documentation it seems like it's possible to override settings
with values in a config file for winform applications. Is the same possible
for web applications.
I have tried to add a connectionstring (under the connectionstring section)
in web.config with the same name as the name in the setting file. The
connectionstring in web.config points to a database that doesn't contain the
required schema. Since I'm not getting any errors and things are still
working, I assume it is still using the default connectionstring supplied at
designtime.Hi Kimbell,
Welcome to ASP.NET newsgroup.
Regarding on the configuration issue you mentioned when using TableAdapter
from class library in asp.net 2.0 project, I've also met this problem
before. Yes, as you has mentioned, when we has build the
DataSet/TableAdapter in class library project, the TableAdapter's
Connection /ConnectionString setting is persisted in the classlibrary
assembly's content so that when referenced in asp.net 2.0 project, it won't
use the web.config file's info (but still use the one persisted at
design-time in classlibrary project). Based on my research, as for the
Project Settings, the asp.net 2.0 seems has different support from winform
project. Currently one approach is manually modify the TableAdapter's
design-time generated code in the Classlibrary project. for example:
the TAbleAdapter's autogenerate code is as below, the "InitConnection"
function is just the one which supply connectionstring and constructing the
Connection instance for the TableAdapter
=============================
private void InitConnection()
{
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString =
DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
}
which retrieve the connection string through Project's Properties.Settings
collection. We can modify it to the following one:
======================
Object obj =
System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
ConnectionStringsSection css = obj as ConnectionStringsSection;
string connstr =
css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString = connstr;
=====================
so that it will retrieve the info from the final hosting application's
application config file (appconfig or web.config).
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXNckyfTDC6JTskQe231gX8p+7Y9A==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "examnotes"
<c_kimbell@.newsgroup.nospam>
| Subject: TableAdapters and web.config
| Date: Mon, 10 Oct 2005 01:12:04 -0700
| Lines: 15
| Message-ID: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349611
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I have a class library that contains a number of TableAdapters and I'm
using
| this from a web application. Is there a way of getting the TableAdapters
to
| use the connectionstrings defined in web.config.
|
| From the MSDN documentation it seems like it's possible to override
settings
| with values in a config file for winform applications. Is the same
possible
| for web applications.
|
| I have tried to add a connectionstring (under the connectionstring
section)
| in web.config with the same name as the name in the setting file. The
| connectionstring in web.config points to a database that doesn't contain
the
| required schema. Since I'm not getting any errors and things are still
| working, I assume it is still using the default connectionstring supplied
at
| designtime.
|
|
So what you are recommending is to change the autogenerated code?
What about the following warning at the top of the file:
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
Particularly the statement about lost changes.
I think a better approach is to change the ConnectionModifier to public in
the designer; then set the connectionstring from code.
I was hoping for a more elegant solution since Microsoft has put some work
into this settings system. Maybe in the next version.
"Steven Cheng[MSFT]" wrote:

> Hi Kimbell,
> Welcome to ASP.NET newsgroup.
> Regarding on the configuration issue you mentioned when using TableAdapter
> from class library in asp.net 2.0 project, I've also met this problem
> before. Yes, as you has mentioned, when we has build the
> DataSet/TableAdapter in class library project, the TableAdapter's
> Connection /ConnectionString setting is persisted in the classlibrary
> assembly's content so that when referenced in asp.net 2.0 project, it won'
t
> use the web.config file's info (but still use the one persisted at
> design-time in classlibrary project). Based on my research, as for the
> Project Settings, the asp.net 2.0 seems has different support from winform
> project. Currently one approach is manually modify the TableAdapter's
> design-time generated code in the Classlibrary project. for example:
> the TAbleAdapter's autogenerate code is as below, the "InitConnection"
> function is just the one which supply connectionstring and constructing th
e
> Connection instance for the TableAdapter
> =============================
> private void InitConnection()
> {
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString =
> DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
> }
> which retrieve the connection string through Project's Properties.Setting
s
> collection. We can modify it to the following one:
> ======================
> Object obj =
> System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
> ConnectionStringsSection css = obj as ConnectionStringsSection;
> string connstr =
> css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString = connstr;
> =====================
> so that it will retrieve the info from the final hosting application's
> application config file (appconfig or web.config).
> Hope helps. Thanks,
> Steven Cheng
> Microsoft Online Support
>
Thanks for your response Kimbell,
Yes, the
========
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
========
you mentioned is really a potential problem with my workaround. And your
appoarch on changing the ConnectionModifer to public is OK for
programmatical accessing. However, in most cases of ASP.NET 2.0 web
application, we will use design-time ObjectDataSource control to reference
the TableAdpater, and this is done through IDE interactively no code is
involved. So in such scenario, we may need to predefined the connection's
initilization in TableAdapter's code.
Anyway, I really appreciate your advice on the configuration setttings ,
and since this is a new feature involved in 2.0, I think it'll be improved
in the sequential versions so as to ease the component, class library
developing and seamless integrated into
front end applications.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
--
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXOO+CVs5sRlZYtRh+M2u+nQzNUBg==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "examnotes"
<c_kimbell@.newsgroup.nospam>
| References: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
<o4v8pDhzFHA.3712@.TK2MSFTNGXA02.phx.gbl>
| Subject: RE: TableAdapters and web.config
| Date: Tue, 11 Oct 2005 01:15:01 -0700
| Lines: 68
| Message-ID: <EAC2EB76-0E98-4837-AD33-55A57F82A6EA@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349877
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So what you are recommending is to change the autogenerated code?
| What about the following warning at the top of the file:
|
| "Changes to this file may cause incorrect behavior and will be lost if
the
| code is regenerated."
|
| Particularly the statement about lost changes.
|
| I think a better approach is to change the ConnectionModifier to public
in
| the designer; then set the connectionstring from code.
|
| I was hoping for a more elegant solution since Microsoft has put some
work
| into this settings system. Maybe in the next version.
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Kimbell,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the configuration issue you mentioned when using
TableAdapter
| > from class library in asp.net 2.0 project, I've also met this problem
| > before. Yes, as you has mentioned, when we has build the
| > DataSet/TableAdapter in class library project, the TableAdapter's
| > Connection /ConnectionString setting is persisted in the classlibrary
| > assembly's content so that when referenced in asp.net 2.0 project, it
won't
| > use the web.config file's info (but still use the one persisted at
| > design-time in classlibrary project). Based on my research, as for the
| > Project Settings, the asp.net 2.0 seems has different support from
winform
| > project. Currently one approach is manually modify the TableAdapter's
| > design-time generated code in the Classlibrary project. for example:
| >
| > the TAbleAdapter's autogenerate code is as below, the "InitConnection"
| > function is just the one which supply connectionstring and constructing
the
| > Connection instance for the TableAdapter
| >
| > =============================
| > private void InitConnection()
| > {
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString =
| > DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
| > }
| >
| > which retrieve the connection string through Project's
Properties.Settings
| > collection. We can modify it to the following one:
| >
| > ======================
| >
| > Object obj =
| >
System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
| > ConnectionStringsSection css = obj as ConnectionStringsSection;
| > string connstr =
| > css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString = connstr;
| >
| > =====================
| >
| > so that it will retrieve the info from the final hosting application's
| > application config file (appconfig or web.config).
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
|
|

TableCaptionAlign Enum missing in Same Version of two System.Web.D

I have 2 System.Web.dll taken from 2 different machines, one of the
System.Web.Dll contains a enum System.Web.UI.WebControls.TableCaptionAlign
and the other did not. I have development a functionality which was not
working in some of the machines and on diggin' into, i found this. I also
compare the 2 dlls through ILDisassembler. Can anyone explain me WHY, WHICH
one should i use?I believe SP1 introduced the new type...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:68A461A9-9DCA-42C0-8795-BC657BF2C6ED@.microsoft.com...
> I have 2 System.Web.dll taken from 2 different machines, one of the
> System.Web.Dll contains a enum System.Web.UI.WebControls.TableCaptionAlign
> and the other did not. I have development a functionality which was not
> working in some of the machines and on diggin' into, i found this. I also
> compare the 2 dlls through ILDisassembler. Can anyone explain me WHY,
WHICH
> one should i use?

TableCaptionAlign Enum missing in Same Version of two System.Web.D

I have 2 System.Web.dll taken from 2 different machines, one of the
System.Web.Dll contains a enum System.Web.UI.WebControls.TableCaptionAlign
and the other did not. I have development a functionality which was not
working in some of the machines and on diggin' into, i found this. I also
compare the 2 dlls through ILDisassembler. Can anyone explain me WHY, WHICH
one should i use?I believe SP1 introduced the new type...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:68A461A9-9DCA-42C0-8795-BC657BF2C6ED@.microsoft.com...
> I have 2 System.Web.dll taken from 2 different machines, one of the
> System.Web.Dll contains a enum System.Web.UI.WebControls.TableCaptionAlign
> and the other did not. I have development a functionality which was not
> working in some of the machines and on diggin' into, i found this. I also
> compare the 2 dlls through ILDisassembler. Can anyone explain me WHY,
WHICH
> one should i use?

tables & rows & columns

I have a table that doesn't line up the way I want it to. I have 6 rows and
3 columns. The 3rd column spans the 6 rows and contains a grid. If the
data in the grid has more than 6 rows of data, the other rows spread out
vertically, as if there is extra space in there. I don't want that to
happen, I want the 6 rows to be together as if there is no space between
then. I have tried using height, valign, using a set height and using a
percentage height and it doesn't work. How can I make the 6 rows on the
left align all the way to the top?
<table borderColor=red cellSpacing=0 cellPadding=0 width="100%" border=1
runat="server" ID="Table1">
<tr vAlign=top colspan=4><td> </td></tr>
<tr vAlign=top>
<td valign=top style="HEIGHT: 15px" align=left width=100>Col 1</td>
<td vAlign=top height=5>Col 2</td>
<td align=right rowspan=6>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br></td>
<td align=left rowspan=6>Col 4</td></tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
</table>Maybe I didn't really get your question, but I do not see a grid in the
3rd column.
But did you try to put another table into one cell? That often works.
Remy Blaettler
www.collaboral.com

tables & rows & columns

I have a table that doesn't line up the way I want it to. I have 6 rows and
3 columns. The 3rd column spans the 6 rows and contains a grid. If the
data in the grid has more than 6 rows of data, the other rows spread out
vertically, as if there is extra space in there. I don't want that to
happen, I want the 6 rows to be together as if there is no space between
then. I have tried using height, valign, using a set height and using a
percentage height and it doesn't work. How can I make the 6 rows on the
left align all the way to the top?

<table borderColor=red cellSpacing=0 cellPadding=0 width="100%" border=1
runat="server" ID="Table1">
<tr vAlign=top colspan=4><td> </td></tr
<tr vAlign=top>
<td valign=top style="HEIGHT: 15px" align=left width=100>Col 1</td>
<td vAlign=top height=5>Col 2</td>
<td align=right rowspan=6>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br></td>
<td align=left rowspan=6>Col 4</td></tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr
</tableMaybe I didn't really get your question, but I do not see a grid in the
3rd column.
But did you try to put another table into one cell? That often works.

Remy Blaettler
www.collaboral.com

Thursday, March 22, 2012

taking a file stream and posting it to a web page

I am getting a stream that contains a PDF file and the task is to get that to a browser for the users. I was able to write code to do this with small files, but there are files so big that it can't be stored in the byte array. I wrote a loop to break down the byte array and it comes accross about the right file size, but Adobe Acrobat can't read it and says it's corrupt. I am thinking there must be a way to write the stream directly into the browser. Why do I need to build a byte array to do things like this (all the examples I find use a byte array)? Is there a way to take the stream and just run it directly into the browser?

Here is the code I have. Works as long as the file doesn't exceed the limits of the byte array:

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

'This returns the stream fine:

Dim msAs Stream = Test3A()

'Show the file on the web page

Dim bytByteStream()AsByte

ms.Seek(0, SeekOrigin.Begin)

ReDim bytByteStream(CType(ms.Length,Integer) - 1)

ms.Read(bytByteStream, 0,CInt(ms.Length))

Dim countAsInteger = 0

While count < ms.Length

bytByteStream(count) = Convert.ToByte(ms.ReadByte())

'bytByteStream(count) = ms.ReadByte()

count += 1

EndWhile

Dim brAs BinaryReader =New BinaryReader(ms)

Response.AddHeader("Content-Type","application/pdf")

Response.AddHeader("Content-Disposition","inline;filename=def.pdf")

Response.BinaryWrite(bytByteStream)

EndSub

Here is the same code with the do loop to break it down (but returns a file to the browser that Adobe Acrobat can't read: PublicSub test3c(ByVal msAs Stream) 'Show the file on the web page Dim bytByteStream()AsByte Dim intByteIndexAsInteger Response.AddHeader("Content-Type","application/pdf") Response.AddHeader("Content-Disposition","inline;filename=def.pdf") IfCType(ms.Length,Integer) > 65000Then intByteIndex = 65000 Else intByteIndex =CType(ms.Length,Integer) EndIf ms.Seek(0, SeekOrigin.Begin) ReDim bytByteStream(intByteIndex - 1) 'ms.Read(bytByteStream, 0, CInt(ms.Length)) Dim countAsInteger = 0 Dim intPlaceAsInteger = 0 Dim intCyclesAsInteger = 0 While count < ms.Length bytByteStream(intPlace) = Convert.ToByte(ms.ReadByte()) count += 1 intPlace += 1 If intPlace = 65000Then Response.BinaryWrite(bytByteStream)'Writes to the browser intCycles += 1 'Increse the cycle meter IfCType(ms.Length,Integer) - (intCycles * 65000) > 65000Then ReDim bytByteStream(65000)'If we have more than 65K more to go, set up for next chunk Else ReDim bytByteStream(CType(ms.Length,Integer) - (intCycles * 65000))'If less than 65K, then put out whatever we have left EndIf intPlace = 0 'Reset the index placment counter EndIf EndWhile Response.BinaryWrite(bytByteStream)

EndSub

MemoryStream outputStream = ' Construct the stream here...

Response.ClearContent()
Response.ClearHeaders()

Response.ContentType = "application/pdf"
Response.AppendHeader("content-disposition", "inline; filename=PDFFile.PDF")
Response.BinaryWrite(outputStream.ToArray())

outputStream.Close()

Response.End()

NC...


NC,

I see what you are going for and it would be great if it could be simple like what you are doing. However, I am getting a 'stream' from an API which I am passing to the procedure we are working on. Standard 'stream' does not have a "ToArray()" method. Is there a way to convert the stream to a memoryStream? Is there a way around this?

Schu


Try this then:

Dim ms As Stream = Test3A()
Dim outputStream As MemoryStream = CType(ms, MemoryStream)
' Rest of code...

NC...


I get the following error:

Unable to cast object of type 'EMC.Centera.BlobStreams.BlobReadStream' to type 'System.IO.MemoryStream'.

It allowed me to pull it out into a byte array as shown in my earlier code, any other ideas on what would work?

Schu


I have no idea what an 'EMC.Centera.BlobStreams.BlobReadStream' is. I tried the cast with a normal Stream object with no problem, so no, I have no idea.

Did you try:
Dim ms As MemoryStream = Test3A()

NC...


Yes, I know, that is from the API. They claim it is coming out as a simple stream (but obviously if it were we wouldn't have issues). I rewrote the code assumeing it was a memorystream and got the error:

Specified argument was out of the range of valid values.
Parameter name: offset

when I got to the "...(outputStream.ToArray()). Any thoughts?


I was looking through the documentation for this vendor code (sparse) and they mention that the stream is a "blobstream". then it says "that is what your VB code will use to Read - the Stream.Read method."

So, is there a way to convert a blob stream into a memorystream?

Schu


Well, since I have no access to the API that you are using, and all the references to "BlobStream" seem to be Java API related, who can tell? I'd request help from the vendor that created the API as I don't think that you will get much help here.

You know, if you could write the BlobStream thing to a temporary file, this would work:

Dim fileName As String = Server.MapPath("~\Reports\TestPdfFile.pdf")

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(fileName)
Response.Flush()
Response.Close()

NC...


Yea, that's a good idea too. Late last night I got together with a couple of the sr devs here and we came up with the following solution that seems to be working. I rem'd out the code that I had in the earlier post so you can see that all I did was remove a section. Thanks for your help! :)

'Show the file on the web page

Dim bytByteStream()AsByte

'ms.Seek(0, SeekOrigin.Begin) ReDim bytByteStream(CType(ms.Length,Integer) - 1) ms.Read(bytByteStream, 0,CInt(ms.Length)) 'Dim count As Integer = 0 'While count < ms.Length ' '>>Following line produces error: ' ' "Value was either too large or too small for an unsigned byte." ' bytByteStream(count) = Convert.ToByte(ms.ReadByte()) ' '>>also tried this which did not work ' ' "Arithmetic operation resulted in an overflow." ' 'bytByteStream(count) = ms.ReadByte() ' count += 1 'End While Response.AddHeader("Content-Type","application/pdf") Response.AddHeader("Content-Disposition","inline;filename=def.pdf")

Response.BinaryWrite(bytByteStream)


Well, I was wondering why you seemed to be filling the Byte array and then refilling it in the loop, but I guess I got side-tracked on the MemoryStream thing. Glad you got it.

NC...

Tuesday, March 13, 2012

Talking between two different web servers

I have two different servers (different ip addresses). They are running IIS. They both have access databases. The first server contains a website.

What is the simplest way to use my website to connect to the other server? My goal is to send information to the access database on the other sever. How can they communicate with one another?

Thanks

Hi,

You can create a web service on the second server. Or you can create a second web site on the second server and receive form data from the first server.


Thanks.

How can I receive data from the second server by receiving form data from the first server? Would I have to set up connection strings specifying both servers? Both servers are located in different regions and not on the same local network. For it to be possible, their IP addresses would have to be unique right? If you know of any on-line references dealing with this subject let me know.

Also these are simple MS Access databases and not MS SQL databases.