Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Wednesday, March 28, 2012

PropertyGrid and SMO objects

With Visual studio 2005 I've mapped my SMO objects and a new PropertyGrid control, everything works fine (a lot thanks to Microsoft VS 2005 team for this wonderfull and power control).

However I have two problems :

1. if I make some change in my PropertyGrid how to apply these changes to related object in my database ?

2. If my user dosn't have enough permission to change my DB objects how to turn PropertyGrid to ReadOnly mode ? ReadOnly property doesn't exist and set Enabled property to false doesn't work since the user cannot navigate through properties

Any help ?

Thank youYou'll need to add an Apply button (or some other control) on your form to give you an event for committing changes. For many SMO classes, you'll be able to commit changes by simply calling the Alter() method on the object that is being displayed in the PropertyGrid.

One way to get the read-only behavior you are looking for would be to create a wrapper class for the SMO class that only exposes property getters for the SMO class properties. If there is only a property getter, the PropertyGrid makes the corresponding cell read-only. So if the user has sufficient privileges, set the SelectedObject property to the SMO object directly, otherwise set the SelectedObject to your read-only wrapper around the SMO object.|||

better put button on propertygrid...

create your own pg and on New()

.......

Dim f As ToolStrip = Me.TOOLSTRIP

Dim n As New ToolStripButton

n.Text = "ADD"

AddHandler n.Click, AddressOf cADD

f.Items.Add(n)

Dim nD As New ToolStripButton

nD.Text = "Save"

AddHandler nD.Click, AddressOf cSave

f.Items.Add(nD)

PropertyGrid and SMO objects

With Visual studio 2005 I've mapped my SMO objects and a new PropertyGrid control, everything works fine (a lot thanks to Microsoft VS 2005 team for this wonderfull and power control).

However I have two problems :

1. if I make some change in my PropertyGrid how to apply these changes to related object in my database ?

2. If my user dosn't have enough permission to change my DB objects how to turn PropertyGrid to ReadOnly mode ? ReadOnly property doesn't exist and set Enabled property to false doesn't work since the user cannot navigate through properties

Any help ?

Thank you

You'll need to add an Apply button (or some other control) on your form to give you an event for committing changes. For many SMO classes, you'll be able to commit changes by simply calling the Alter() method on the object that is being displayed in the PropertyGrid.

One way to get the read-only behavior you are looking for would be to create a wrapper class for the SMO class that only exposes property getters for the SMO class properties. If there is only a property getter, the PropertyGrid makes the corresponding cell read-only. So if the user has sufficient privileges, set the SelectedObject property to the SMO object directly, otherwise set the SelectedObject to your read-only wrapper around the SMO object.|||

better put button on propertygrid...

create your own pg and on New()

.......

Dim f As ToolStrip = Me.TOOLSTRIP

Dim n As New ToolStripButton

n.Text = "ADD"

AddHandler n.Click, AddressOf cADD

f.Items.Add(n)

Dim nD As New ToolStripButton

nD.Text = "Save"

AddHandler nD.Click, AddressOf cSave

f.Items.Add(nD)

Monday, March 26, 2012

Properties List

Where can I get a list of all the properties for a control such as a textbox?The RDL documentation lists all properties for all controls. From
programming standpoint, the only Textbox property exposed to you is the
Value property.
--
HTH,
---
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/
---
"David" <David@.discussions.microsoft.com> wrote in message
news:F033C6DF-06FF-423B-8F5C-DB99E00BD085@.microsoft.com...
> Where can I get a list of all the properties for a control such as a
> textbox?

Tuesday, March 20, 2012

Project question.

Project question.
Hi, I'm developing a DB that is as follow:
This DB is for control the Credit Cards information. Then it has a lot of
movement.
1-I have a client.
2-This client has an account
3-This account can has a many cards ( for exemple: credit card
international, credit card gold.) each one whit your rules (like: limit,
date of pay.)
4- And I have a table that receives all transactions, for example: (very
simplified)
Client '1010 1010 1010 1010' buy product that have cost of $100,00 ,date
05/05/05
Client '1010 1010 1010 1010' buy product that have cost of $50,00 , date
05/20/05
.
Client '2020 2020 2020 2020' buy product that have cost of $80,00 ,date
05/04/05
Client '2020 2020 2020 2020' buy product that have cost of $50,00 , date
05/18/05
.
I need made calculations to generate a bill for each client each month.
My question is: When I have 1 million of client (consequently 5 million of
transaction in this table to month) and I need make calculations, this table
will work. (It won't be locked)
How I should do this.
Anyone have experience with a lot of data. How work with a lot of data that
need be calculate.
Any think is important to me.
Thank you very much.Hello,
You may want to consider use Horizontal partitioning
http://msdn.microsoft.com/library/d...-us/optimsql/od
p_tun_1_11ev.asp
http://www.sqlteam.com/Item.ASP?ItemID=684
Also, general query optimation is necesary for each specific query:
HOW TO: Troubleshoot Slow-Running Queries on SQL Server 7.0 or Later
http://support.microsoft.com/?id=243589
http://www.sql-server-performance.com/mr_indexing.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/?id=311826
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
| From: "ReTF" <re.tf@.newsgroup.nospam>
| Subject: Project question.
| Date: Wed, 3 Aug 2005 09:32:57 -0300
| Lines: 74
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <OjmzhbCmFHA.3256@.TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.programming
| NNTP-Posting-Host: 200-211-161-64-amr.cpe.vivax.com.br 200.211.161.64
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.programming:109244
| X-Tomcat-NG: microsoft.public.sqlserver.programming
|
| Project question.
|
|
|
| Hi, I'm developing a DB that is as follow:
|
|
|
| This DB is for control the Credit Cards information. Then it has a lot of
| movement.
|
|
|
| 1-I have a client.
|
| 2-This client has an account
|
| 3-This account can has a many cards ( for exemple: credit card
| international, credit card gold.) each one whit your rules (like: limit,
| date of pay.)
|
| 4- And I have a table that receives all transactions, for example: (very
| simplified)
|
|
|
| Client '1010 1010 1010 1010' buy product that have cost of $100,00 ,date
| 05/05/05
|
| Client '1010 1010 1010 1010' buy product that have cost of $50,00 , date
| 05/20/05
|
| .
|
| Client '2020 2020 2020 2020' buy product that have cost of $80,00 ,date
| 05/04/05
|
| Client '2020 2020 2020 2020' buy product that have cost of $50,00 , date
| 05/18/05
|
| .
|
|
|
| I need made calculations to generate a bill for each client each month.
|
|
|
| My question is: When I have 1 million of client (consequently 5 million
of
| transaction in this table to month) and I need make calculations, this
table
| will work. (It won't be locked)
|
|
|
| How I should do this.
|
|
|
| Anyone have experience with a lot of data. How work with a lot of data
that
| need be calculate.
|
|
|
|
|
| Any think is important to me.
|
|
|
| Thank you very much.
|
|
|
|
|

Monday, March 12, 2012

Programming report viewer at run time

I have a report that works. It has been added to a webform (dot net 2.0)
that works. It has an image control in the upper left hand of the page
header. I would like to be able to change that graphic depending on a sql
table setting as the web form loads,
Does anyone know of a good detailed example of how to do this?
I have tried this and it does NOT work:
Dim myImage1 As New Image
myImage1 = Me.ReportViewer1.FindControl("Image1")
myImage1.ImageUrl = "Images/small_info_logo.jpg"
Thanks
ChuckOn Apr 20, 9:58 pm, ChuckT <Chu...@.discussions.microsoft.com> wrote:
> I have a report that works. It has been added to a webform (dot net 2.0)
> that works. It has an image control in the upper left hand of the page
> header. I would like to be able to change that graphic depending on a sql
> table setting as the web form loads,
> Does anyone know of a good detailed example of how to do this?
> I have tried this and it does NOT work:
> Dim myImage1 As New Image
> myImage1 = Me.ReportViewer1.FindControl("Image1")
> myImage1.ImageUrl = "Images/small_info_logo.jpg"
> Thanks
> Chuck
Instead of setting the ImageUrl in the web form, set it in the report
itself. You should be able to provide an Expression value for the
ImageUrl in the report builder - just point it to a dataset (possibly
using the Iif() function if the url is not stored in the database
records).
- Tokes|||Great idea, thank you very much. Plus it is a simplier implementation
Chuck
"Tokes" wrote:
> On Apr 20, 9:58 pm, ChuckT <Chu...@.discussions.microsoft.com> wrote:
> > I have a report that works. It has been added to a webform (dot net 2.0)
> > that works. It has an image control in the upper left hand of the page
> > header. I would like to be able to change that graphic depending on a sql
> > table setting as the web form loads,
> >
> > Does anyone know of a good detailed example of how to do this?
> >
> > I have tried this and it does NOT work:
> > Dim myImage1 As New Image
> > myImage1 = Me.ReportViewer1.FindControl("Image1")
> > myImage1.ImageUrl = "Images/small_info_logo.jpg"
> >
> > Thanks
> >
> > Chuck
> Instead of setting the ImageUrl in the web form, set it in the report
> itself. You should be able to provide an Expression value for the
> ImageUrl in the report builder - just point it to a dataset (possibly
> using the Iif() function if the url is not stored in the database
> records).
> - Tokes
>|||Actually that will not work. If you use any external pointer the designer
imports the garphic at design time. I am hoping to get a run time interrface
that loads the graphic based on a table value.
"ChuckT" wrote:
> Great idea, thank you very much. Plus it is a simplier implementation
> Chuck
> "Tokes" wrote:
> > On Apr 20, 9:58 pm, ChuckT <Chu...@.discussions.microsoft.com> wrote:
> > > I have a report that works. It has been added to a webform (dot net 2.0)
> > > that works. It has an image control in the upper left hand of the page
> > > header. I would like to be able to change that graphic depending on a sql
> > > table setting as the web form loads,
> > >
> > > Does anyone know of a good detailed example of how to do this?
> > >
> > > I have tried this and it does NOT work:
> > > Dim myImage1 As New Image
> > > myImage1 = Me.ReportViewer1.FindControl("Image1")
> > > myImage1.ImageUrl = "Images/small_info_logo.jpg"
> > >
> > > Thanks
> > >
> > > Chuck
> >
> > Instead of setting the ImageUrl in the web form, set it in the report
> > itself. You should be able to provide an Expression value for the
> > ImageUrl in the report builder - just point it to a dataset (possibly
> > using the Iif() function if the url is not stored in the database
> > records).
> >
> > - Tokes
> >
> >|||On Apr 21, 11:12 am, ChuckT <Chu...@.discussions.microsoft.com> wrote:
> Actually that will not work. If you use any external pointer the designer
> imports the garphic at design time. I am hoping to get a run time interrface
> that loads the graphic based on a table value.
That shouldn't be the case if you're setting the Url to an
expression... also check that the image control is not set to
'embedded'?
- Tokes
> "ChuckT" wrote:
> > Great idea, thank you very much. Plus it is a simplier implementation
> > Chuck
> > "Tokes" wrote:
> > > On Apr 20, 9:58 pm, ChuckT <Chu...@.discussions.microsoft.com> wrote:
> > > > I have a report that works. It has been added to a webform (dot net 2.0)
> > > > that works. It has an image control in the upper left hand of the page
> > > > header. I would like to be able to change that graphic depending on a sql
> > > > table setting as the web form loads,
> > > > Does anyone know of a good detailed example of how to do this?
> > > > I have tried this and it does NOT work:
> > > > Dim myImage1 As New Image
> > > > myImage1 = Me.ReportViewer1.FindControl("Image1")
> > > > myImage1.ImageUrl = "Images/small_info_logo.jpg"
> > > > Thanks
> > > > Chuck
> > > Instead of setting the ImageUrl in the web form, set it in the report
> > > itself. You should be able to provide an Expression value for the
> > > ImageUrl in the report builder - just point it to a dataset (possibly
> > > using the Iif() function if the url is not stored in the database
> > > records).
> > > - Tokes

Programmatically setting UpdateParameters for a SQLDataSource control

I need to provide defaultsand sometimes overrides for items in SQLDataSource's UpdateParameters. I am attempting to do this in a FormView's ItemUpdating and ItemInserting events as follows:

//======================================================================== // FormView1_ItemUpdating: //========================================================================protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) {// not sure if this is the bets place to put this or not? dsDataSource.UpdateParameters["UpdatedTS"].DefaultValue = DateTime.Now.ToString(); dsDataSource.UpdateParameters["UpdatedUserID"].DefaultValue = ((csi.UserInfo)Session["UserInfo"]).QuotaUserID; } 
In the example above I am attempting to set new values for the parameters which will replace the existing values.
I have found that using the DefaultValue property works ONLY if there is no current value for the parameter. Otherwise the values I specify are ingnored.
The parameters of an ObjectDataSource provide aValue property but SQLDataSource parameters do not.
How can I provide an override value without needing to place the value in the visible bound form element?

If you can answer this you will be the FIRST person ever to answer one of my questions here!!!
Thanks,
Tony
 

I figured it out. I still don't know if this is the best way to provide defaults but this works. If anyone has a better method I would appreciate any input

You can use the NewValues property of FormViewUpdateEventArgs and the Values property of FormViewInsertEventArgs

//======================================================================== // FormView1_ItemUpdating: //========================================================================protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) {// not sure if this is the bets place to pout this or not? e.NewValues["UpdatedTS"] = DateTime.Now.ToString(); e.NewValues["UpdatedUserID"] = ((csi.UserInfo)Session["UserInfo"]).QuotaUserID; }

Wednesday, March 7, 2012

Programmatically change a textbox's contents

Quick question... I have a C# ASP.Net (2.0) webpage with a ReportViewer
control on it. In the code-behind I set the datasource of the report and
then view the report data:
DataSet ds = DBProvider.GetDataSet(SQL, DateFrom, DateTo);
rvRR310.LocalReport.ReportPath = "RR310.rdlc";
rvRR310.LocalReport.DataSources.Clear();
rvRR310.LocalReport.DataSources.Add(new
ReportDataSource("Reports_stp_RR310_Export", ds.Tables[0]));
"DBProvider" is a class I made to talk to the SQL Server and "RR310.rdlc" is
the actual report itself. The query that is executed accepts a couple
parameters (start date and end date) for the data that is to be returned.
My issue is not with this part, as everything up to this point works great.
What I am trying to figure out how to do is access the report itself, so I
can change the contents of a textbox I put there. I want to take the query
parameters and stuff them into the report textbox so I can have it say
something like "Date Range: <start> to <end>". The problem is I can't
figure out how to write the code to allow me to do this.
Anyone have a suggestion or pointer? Thanks!
-- AndrewOn May 23, 5:10 pm, "Andrew" <andrewr2k1@.n0r3ply_hotmail.com> wrote:
> Quick question... I have a C# ASP.Net (2.0) webpage with a ReportViewer
> control on it. In the code-behind I set the datasource of the report and
> then view the report data:
> DataSet ds = DBProvider.GetDataSet(SQL, DateFrom, DateTo);
> rvRR310.LocalReport.ReportPath = "RR310.rdlc";
> rvRR310.LocalReport.DataSources.Clear();
> rvRR310.LocalReport.DataSources.Add(new
> ReportDataSource("Reports_stp_RR310_Export", ds.Tables[0]));
> "DBProvider" is a class I made to talk to the SQL Server and "RR310.rdlc" is
> the actual report itself. The query that is executed accepts a couple
> parameters (start date and end date) for the data that is to be returned.
> My issue is not with this part, as everything up to this point works great.
> What I am trying to figure out how to do is access the report itself, so I
> can change the contents of a textbox I put there. I want to take the query
> parameters and stuff them into the report textbox so I can have it say
> something like "Date Range: <start> to <end>". The problem is I can't
> figure out how to write the code to allow me to do this.
> Anyone have a suggestion or pointer? Thanks!
> -- Andrew
If I understand you correctly, you should be able to achieve this by
referencing the report parameters. Something like this should work as
expressions in the textbox controls in the report itself.
=Parameters!StartDate.Value
=Parameters!EndDate.Value
Regards,
Enrique Martinez
Sr. Software Consultant|||I would agree with you if the report knew about the parameters, but the
report never sees them. As shown in the code snippet, I pass the SQL stored
procedure, and the arguments, to a method of my class that talks to the SQL
Server. It passes back a dataset which I then assign to the report. The
report only knows about the data, not any parameters.
Let me ask the question another way...
From the .cs page that has the ReportViewer control, how can I change the
text of a TextBox inside the report. Never mind where or what the content
is coming from, just, how do I change the text from outside the report
itself and at runtime?
"EMartinez" <emartinez.pr1@.gmail.com> wrote in message
news:1179970516.364360.86270@.m36g2000hse.googlegroups.com...
> On May 23, 5:10 pm, "Andrew" <andrewr2k1@.n0r3ply_hotmail.com> wrote:
>
> If I understand you correctly, you should be able to achieve this by
> referencing the report parameters. Something like this should work as
> expressions in the textbox controls in the report itself.
> =Parameters!StartDate.Value
> =Parameters!EndDate.Value
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||I found the answer to my question....
First step is to set up a Report Parameter (as many as you need for whatever
it is you need to do).
Second, add a TextBox to the report, and then under Expressions, set it to
display the Parameter you desire.
Last, in the .cs page that loads the ReportViewer control, add the following
code:
ReportParameter[] params = new ReportParameter[2];
params[0] = new ReportParameter("DateFrom", "ProductShipped", false);
params[1] = new ReportParameter("DateTo", "@.parameter1", false);
this.reportViewer.LocalReport.SetParameters(params);
Of course, change the names and size to suit your needs.
Pretty simple and straightforward, and works very nicely with what I wanted
to do.
-- Andrew
"Andrew" <andrewr2k1@.n0r3ply_hotmail.com> wrote in message
news:e413UcYnHHA.4476@.TK2MSFTNGP02.phx.gbl...
> Quick question... I have a C# ASP.Net (2.0) webpage with a ReportViewer
> control on it. In the code-behind I set the datasource of the report and
> then view the report data:
> DataSet ds = DBProvider.GetDataSet(SQL, DateFrom, DateTo);
> rvRR310.LocalReport.ReportPath = "RR310.rdlc";
> rvRR310.LocalReport.DataSources.Clear();
> rvRR310.LocalReport.DataSources.Add(new
> ReportDataSource("Reports_stp_RR310_Export", ds.Tables[0]));
> "DBProvider" is a class I made to talk to the SQL Server and "RR310.rdlc"
> is the actual report itself. The query that is executed accepts a couple
> parameters (start date and end date) for the data that is to be returned.
> My issue is not with this part, as everything up to this point works
> great. What I am trying to figure out how to do is access the report
> itself, so I can change the contents of a textbox I put there. I want to
> take the query parameters and stuff them into the report textbox so I can
> have it say something like "Date Range: <start> to <end>". The problem is
> I can't figure out how to write the code to allow me to do this.
> Anyone have a suggestion or pointer? Thanks!
> -- Andrew
>