Showing posts with label creates. Show all posts
Showing posts with label creates. Show all posts

Tuesday, February 14, 2012

Button1_click code behind

Hi, I have the following code which creates a dropdown box with values from the database.

1) I would like an sql statement to take place to update the database. When the button is clicked I would like the database to update so 'doc_area_default' is changed to '1' for the value that is selected via the dropdown. All others should be changed to '0'. Then direct the user to ManageAreas.aspx with a success message.

2) I would like to be able to do this in the code behind page (cs). Using the "protectedvoid Button1_Click(object sender,EventArgs e)" method. I'm not sure how to do the database connection like I would in the aspx page either.

Thanks for any help you can give!

<

asp:DropDownListID="DropDownList1"runat="server"DataSourceID="SqlDataSource1"DataTextField="doc_area_name"DataValueField="doc_area_id"></asp:DropDownList><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:CPS_docshareConnectionString %>"SelectCommand="SELECT * FROM [document_area] WHERE [doc_area_type] = 1 ORDER BY [doc_area_default] DESC"></asp:SqlDataSource>

<

asp:ButtonID="Button1"runat="server"Text="Update"OnClick="Button1_Click"/>

Dearmlawton40 .

I guess u can use store procedure to do this.

Try to use these code

//Create procedure

create proc sp_update

@.doc_area_id int

as

update document_area set doc_area_type=1 where [doc_area_id] = @.doc_area_id

update document_area set doc_area_type=0 where [doc_area_id] <> @.doc_area_id

go

And Code behind your page

public void Button1_Click()
{


SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["CPS_docshareConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("sp_update", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@.doc_area_id",DropDownList1.selectedvalue));
cmd.Connection.Open();
cmd.ExecuteNonQuery();

Response.Redirect("ManageAreas.aspx");
}

Hope that it will help you..

Business Objects and Db Performance

I'm new to Business Objects, and I have a question to ask,

Does creating universe in the designer actually creates indexes in the DB? Or universe is just a reference model for the BO app.

If so, won't poor designed universe slow down DB performance?

For those who have experience in BO, please advise. Thanks.In my experience BO does not create any indexes in the DB. And yes, universe design is very important as poor universe design will lead to poor performance.. I am using BO 5.1.?, I'm not sure what version you are using.

Any more questions please let me know.

Thanks,

Originally posted by Patrick Chua
I'm new to Business Objects, and I have a question to ask,

Does creating universe in the designer actually creates indexes in the DB? Or universe is just a reference model for the BO app.

If so, won't poor designed universe slow down DB performance?

For those who have experience in BO, please advise. Thanks.