Showing posts with label group. Show all posts
Showing posts with label group. Show all posts

Saturday, March 24, 2012

Newbie: Static Method Instantiating Itself To Acess Non-static Propertys. Ok?

Hello,

I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.

I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.

I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).

One thing of note:

1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)

The code below gives an example.

using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;

namespace GoDAT.Venue
{

public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~

// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion

private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~

// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~

// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{

Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;

tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}

return tmpDS;
}
// ~~~~~
}
}"Electric Co." <jmcphee@.ucalgary.cawrote in message
news:1155145846.449750.188470@.m79g2000cwm.googlegr oups.com...

What you did seems to be ok, however I would create a private static field
to your class and create your Venue object there. E.g

private static Venue venue = new Venue();

Then this variable could be access by all other methods in this class and
you only have to create this object once. Also, if you want to prevent this
class from begin created by some client code you could also make your
constructor private.

HTH

Quote:

Originally Posted by

Hello,
>
I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.
>
>
I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.
>
I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).
>
One thing of note:
>
1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)
>
The code below gives an example.
>
>
>
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;
>
namespace GoDAT.Venue
{
>
public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~
>
// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion
>
private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~
>
// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~
>
// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{
>
Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;
>
tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}
>
return tmpDS;
}
// ~~~~~
}
}
>


"Electric Co." <jmcphee@.ucalgary.cawrote in message
news:1155145846.449750.188470@.m79g2000cwm.googlegr oups.com...
You don't have to do what I suggested, you may been to weigh the pro's and
con's first before you do.

Quote:

Originally Posted by

Hello,
>
I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.
>
>
I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.
>
I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).
>
One thing of note:
>
1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)
>
The code below gives an example.
>
>
>
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;
>
namespace GoDAT.Venue
{
>
public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~
>
// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion
>
private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~
>
// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~
>
// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{
>
Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;
>
tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}
>
return tmpDS;
}
// ~~~~~
}
}
>


Hi,

Thanx, I thought your suggestion was brilliant.

Jim

Thursday, March 22, 2012

Newby/Novice Question: Printing Web Pages...

Hello, I have a question for the group.
My current project uses multiple panels to display the contents of a
web page. The thing is many of these panels are hidden while only one
is visible at a time (much like tabs). I use a set of command buttons
to switch between these panels. What I would like to do is to create a
print function that will create a preview showing all panels in
sequential order which could be used to print a hard copy.
Any suggestions?
TIA...The simple answer is: Use CSS to do the dirty work
You can set up different stylesheets for screen and print (an example
to follow)
BUT:
It all depends on your app
Is all your data easily available upfront? is there a lot of overhead
involved in fecthing data to be displayed on the other "tab"s
Are your clients on a low latency connection to the server?
EXAMPLE:
<STYLE type="text/css">
@.media print { .ScreenOnly { display: none; } }
@.media screen { .PrintOnly { display: none; }
.TabContentHidden { display: none; visibility: hidden; } }
</STYLE>
<DIV class="ScreenOnly" >This content will not be printed</DIV>
<DIV class="PrintOnly" >This content will not be visible on screen, but
<B>will</B> be printed</DIV>
<DIV class="TabContentHidden" >This is an invisible panel (but will
print)</DIV><DIV class="TabContent" >This is the visible panel (both
print and screen)</DIV>
<DIV class="TabContentHidden" >This is an invisible panel (but will
print)</DIV>
The other advantage to this approach is that you can switch "tabs" on
the browser without the server roundtrips (read near-instantaneous)
Hope this helps
-- addup --
Hmmm.
That looks interesting and might work if I had things setup "normally"
but that approch wouldn't work, I think. I am using ASPdotNET (i.e.
postbacks) to make the different panels/DIVs visible or not. If a
panel is not set as visible by the server it doesn't even show up on
the client side.
Private Sub btnPg1_Click(sender as Object, e as EventArgs) Handles
btnPg1.Click
pnlPg1.Visible = True
pnlPg2.Visible = False
pnlPg3.Visible = False
pnlPg4.Visible = False
pnlPg5.Visible = False
End Sub
Is there perhaps more of a dotNET approach?
TIA...
I guess I should lookup more on that CSS stuff.
You will have to change from ASP.Net Visibility to CSS visiblity:
pnlPg1.Visible = true
pnlPg1.Attributes.Add("display", "");
pnlPg2.Visible = true
pnlPg2.Attributes.Add("display", "none");
pnlPg3.Visible = true
pnlPg3.Attributes.Add("display", "none");
pnlPg4.Visible = true
pnlPg4.Attributes.Add("display", "none");
then in your HTML add
<link href="http://links.10026.com/?link=print.css" type="text/css" rel="stylesheet" media="print">
print.css:
--
#pnlPg1 { display:; }
#pnlPg2 { display:; }
#pnlPg3 { display:; }
#pnlPg4 { display:; }
#pnlPg5 { display:; }
When you change the Visible Property in .NET it doesn't ever render the
control to the browser. If you have all the Visible Properties set to true
and use the css style display attribute = "" (blank-visible) or "none"
(invisible). Then every panel is rendered to the browser and you control
the visiblity on the client side using CSS
So the page uses the default CSS from you code on the screen layout, then
when you print using the it uses the printCSS and will make all panels
visible.
Let us know if this works.
what's "normal" anyway.
While *I* wouldn't do it this way, there's nothing wrong with your
approach
For your case
Set up another command button btnPrint
Private Sub btnPrint_Click(sender as Object, e as EventArgs) Handles
btnPrint.Click
pnlPg1.Visible = True
pnlPg2.Visible = True
pnlPg3.Visible = True
pnlPg4.Visible = True
pnlPg5.Visible = True
Page.RegisterStartupScript("PrintScript", "<SCRIPT
language='javascript'>window.print(); history.back();</SCRIPT>")
End Sub
I would probably have to agree. Setting up a print page would definately be
cleaner
JavaScript to the rescue!...again
I remember using a LOT of JavaScript with ASP.Classic
That gave me something to work with.
Thanks.
Ben Dewey wrote:
> I would probably have to agree. Setting up a print page would definately
be
> cleaner

Newie needs data access

I was not sure which group deals with this is I apologize.
I need to connect to an MS Access DB and add. delete & update from an ASPX
page (using vb.net for code behind if needed)

Are there any sites that show code snippets ?
Both DSN & DSNless connections please

I can find them for ASP but none for aspx
Looks like aspx uses ado.net instead of ado & code is probably different if
only slightly (I don't know)

Thanks a lot in advance.Hi Ralf,

ASPX (that is, ASP .NET) pages indeed use ADO .NET. ADO .NET, in turn, can
talk to the Microsoft Jet OLEDB provider through its Managed OLEDB Provider
found in the System.Data.OleDB namespace. As far as I remember DSNs are
related to ODBC and ODBC is not a native way of working with MS Access
databases. So, you will be using OLEDB-compatible connection strings as if
you were working with the Jet OLEDB provider.

You can find information and examples on working with ADO .NET in the
"Accessing Data with ADO.NET" on the MSDN Library
(http://msdn.microsoft.com/library).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"ralf" <--__0ralfr@.yahoo.com> wrote in message
news:bluefh$gisue$1@.ID-158805.news.uni-berlin.de...
> I was not sure which group deals with this is I apologize.
> I need to connect to an MS Access DB and add. delete & update from an ASPX
> page (using vb.net for code behind if needed)
> Are there any sites that show code snippets ?
> Both DSN & DSNless connections please
> I can find them for ASP but none for aspx
> Looks like aspx uses ado.net instead of ado & code is probably different
if
> only slightly (I don't know)
> Thanks a lot in advance.
Thanks for posting but unfortunately I have no time to reinvent the wheel by
studying ado.net from scratch
I posted because someone may already have written the code that I can reuse
and that is what I am
looking for .

"Dmitriy Lapshin [C# / .NET MVP]" <x-code@.no-spam-please.hotpop.com> wrote
in message news:etZaLeNjDHA.4048@.TK2MSFTNGP11.phx.gbl...
> Hi Ralf,
> ASPX (that is, ASP .NET) pages indeed use ADO .NET. ADO .NET, in turn, can
> talk to the Microsoft Jet OLEDB provider through its Managed OLEDB
Provider
> found in the System.Data.OleDB namespace. As far as I remember DSNs are
> related to ODBC and ODBC is not a native way of working with MS Access
> databases. So, you will be using OLEDB-compatible connection strings as if
> you were working with the Jet OLEDB provider.
> You can find information and examples on working with ADO .NET in the
> "Accessing Data with ADO.NET" on the MSDN Library
> (http://msdn.microsoft.com/library).
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
> http://x-unity.miik.com.ua/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE
> "ralf" <--__0ralfr@.yahoo.com> wrote in message
> news:bluefh$gisue$1@.ID-158805.news.uni-berlin.de...
> > I was not sure which group deals with this is I apologize.
> > I need to connect to an MS Access DB and add. delete & update from an
ASPX
> > page (using vb.net for code behind if needed)
> > Are there any sites that show code snippets ?
> > Both DSN & DSNless connections please
> > I can find them for ASP but none for aspx
> > Looks like aspx uses ado.net instead of ado & code is probably different
> if
> > only slightly (I don't know)
> > Thanks a lot in advance.

Friday, March 16, 2012

News Group Display

Is there any way to download the contents of a news group such that it can
be displayed via a web page.

TIA

Derek

--
_______________________________________________

www.windowsmce.com - Windows Media Center Edition UKHi Derek:

You'll want to search for an NNTP component you can use from .NET. I'm
sure there are free ones available but I do not have any to recommend.

--
Scott
http://www.OdeToCode.com/

On Tue, 05 Oct 2004 15:36:07 GMT, "DJY\(www.windowsmce.com\)"
<djy2000@.ntlworld.com> wrote:

>Is there any way to download the contents of a news group such that it can
>be displayed via a web page.
>TIA
>Derek
Cheers

D

"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:l5h5m0h4dna887g8n6g2g3n5pn5ar8kjrt@.4ax.com...
> Hi Derek:
> You'll want to search for an NNTP component you can use from .NET. I'm
> sure there are free ones available but I do not have any to recommend.
> --
> Scott
> http://www.OdeToCode.com/
> On Tue, 05 Oct 2004 15:36:07 GMT, "DJY\(www.windowsmce.com\)"
> <djy2000@.ntlworld.com> wrote:
>>Is there any way to download the contents of a news group such that it can
>>be displayed via a web page.
>>
>>TIA
>>
>>Derek

News Group Display

Is there any way to download the contents of a news group such that it can
be displayed via a web page.
TIA
Derek
________________________________________
_______
www.windowsmce.com - Windows Media Center Edition UKHi Derek:
You'll want to search for an NNTP component you can use from .NET. I'm
sure there are free ones available but I do not have any to recommend.
Scott
http://www.OdeToCode.com/
On Tue, 05 Oct 2004 15:36:07 GMT, "DJY\(www.windowsmce.com\)"
<djy2000@.ntlworld.com> wrote:

>Is there any way to download the contents of a news group such that it can
>be displayed via a web page.
>TIA
>Derek
Cheers
D
"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:l5h5m0h4dna887g8n6g2g3n5pn5ar8kjrt@.
4ax.com...
> Hi Derek:
> You'll want to search for an NNTP component you can use from .NET. I'm
> sure there are free ones available but I do not have any to recommend.
> --
> Scott
> http://www.OdeToCode.com/
> On Tue, 05 Oct 2004 15:36:07 GMT, "DJY\(www.windowsmce.com\)"
> <djy2000@.ntlworld.com> wrote:
>
>