Showing posts with label specify. Show all posts
Showing posts with label specify. Show all posts

Monday, March 12, 2012

Programmatically Specify SqlDataSource Parameters

I have a GridView bound to a SqlDataSource. On page load I would like to programmatically specify a SelectParameter value based on the role of the user. This SelectParameter will be used in my WHERE clause. The closest post I can find ishttp://forums.asp.net/thread/1233258.aspx but no answer was posted.

What code would I use to modify a SelectParameters value? Is it possible to reference a parameter by name (SqlDataSource1.SelectParameters["usertype"]) or does it have to be by index? (SqlDataSource1.SelectParameters[0])

Alternatively, perhaps I'm going about this in the wrong way, is there a better way to have dynamic GridView content based on the role of the user?

Thank you very much for your help.

Yes, you can set the value of a select parameters by name, for example
SqlDataSource1.SelectParameters["usertype"].DefaultValue ="role"
|||

Both parameter name and index are working here.

protected

void Page_Load(object sender,EventArgs e)

{

SqlDataSource1.SelectParameters[0].DefaultValue=

"yourvalue";

or

SqlDataSource1.SelectParameters["usertype"].DefaultValue="yourvalue";

}

|||

You can also set the value in the SqlDataSource_Selecting event via the e parameter:

Private Sub SqlDataSource1_Selecting(stuff)

e.command.paramter("param1").value=something

end sub

Programmatically Set Sever Timeout Using AMO Classes and Objects

Using DSO object model, We use to Specify the Server Timeout for 4 hours as follows:

oServer.Timeout = 14400

But using the AMO Classes and Objects, How will I set the Server timeout programmatically?

Many Thanks

Subhash Subramanyam

hello Subhash,

i think you can specify the Timeout property in connection string. I.e. something like this:

Server server = new Server();

server.Connect("Data Source=localhost; Timeout=14400;");

// do something

server.Disconnect();

(there is also a Timeout property on DataSource object - though that one affects data source connection i think).

hope this helps,

|||

Hi Mary,

Thanks for the reply, I got what I was looking for.

Wednesday, March 7, 2012

Programmatically adding new column at desired place...not at the end

I understand that adding new column programmatically (using ALTER TABLE...),
adds it at the end of the table. Is it possible to specify that this column
should be placed at the 3rd place (not at the end).
Thanks in advance
J JustinHi Justin,
No, You can not do that. Only way for that is to drop and recreate the table
with new order.
Thanks
Hari
SQL Server MVP
"Justin" <justin@.gjsoft.com> wrote in message
news:%231cEsy0NFHA.2736@.tk2msftngp13.phx.gbl...
> I understand that adding new column programmatically (using ALTER
> TABLE...),
> adds it at the end of the table. Is it possible to specify that this
> column
> should be placed at the 3rd place (not at the end).
> Thanks in advance
>
> J Justin
>
>|||As Hari said, you can't without dropping and recreating the table. And your
code shouldn't be dependent on the physical order of the columns. Logically
speaking, columns in a table do not have an order. All references to columns
should be by name and not by ordinal.
Jacco Schalkwijk
SQL Server MVP
"Justin" <justin@.gjsoft.com> wrote in message
news:%231cEsy0NFHA.2736@.tk2msftngp13.phx.gbl...
> I understand that adding new column programmatically (using ALTER
> TABLE...),
> adds it at the end of the table. Is it possible to specify that this
> column
> should be placed at the 3rd place (not at the end).
> Thanks in advance
>
> J Justin
>
>|||http://www.aspfaq.com/2528
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Justin" <justin@.gjsoft.com> wrote in message
news:#1cEsy0NFHA.2736@.tk2msftngp13.phx.gbl...
> I understand that adding new column programmatically (using ALTER
TABLE...),
> adds it at the end of the table. Is it possible to specify that this
column
> should be placed at the 3rd place (not at the end).
> Thanks in advance
>
> J Justin
>
>

Monday, February 20, 2012

Programatically creating linked reports with parameters

hi,
I am trying to programmatically create a linked report and I'm not sure how
to specify the parameters for this linked report.
Essentially, I have a parameterized report and a list of values for all the
parameters in this report, entered by the user from my custom website.
The idea is that I collect the parameter values from the user and process
the report in the background. I can then notify the user that their report
is ready for viewing and they can view it without having to wait.
I think a linked report is the way to go, but maybe this isn't the way to do
this.
Thanks,
MattI was able to use SetReportParameters() to set the parameters for the linked
report.
Matt
"mshumaker" wrote:
> hi,
> I am trying to programmatically create a linked report and I'm not sure how
> to specify the parameters for this linked report.
> Essentially, I have a parameterized report and a list of values for all the
> parameters in this report, entered by the user from my custom website.
> The idea is that I collect the parameter values from the user and process
> the report in the background. I can then notify the user that their report
> is ready for viewing and they can view it without having to wait.
> I think a linked report is the way to go, but maybe this isn't the way to do
> this.
> Thanks,
> Matt