Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Sunday, March 25, 2012

Deleting from SQL table using two arguments

I am trying to delete from a SQL table using two arguments, I currently use the following on the aspx page:

<ItemTemplate>
<asp:LinkButton ID="cmdDeleteJob" runat="server" CommandName="CancelJob" Text="Delete" CssClass="CommandButton" CommandArgument='<%# Bind("Type_of_service") %>' OnClientClick="return confirm('Are you sure you want to delete this item?');"></asp:LinkButton>
</ItemTemplate>

and then I use the following on the aspx.vb page:

If e.CommandName = "CancelJob" Then

Dim typeService As Integer = CType(e.CommandArgument, Integer)
Dim typeDesc As String = ""

Dim wsDelete As New page1
wsDelete.deleteAgencySvcs(typeService)

gvTech.DataBind()

I need to be able to pick up two CommandArguments.

Is this Template in a GridView? if so, is the second argument the same for all rows? if yes, then store that arugment in the DataKeyNames property of the grid. If not, then you can try using a pipe or literal separator for your command argument and then parse it out in the handler by using split().

Hope that helps,

--D

|||

Hi dannyo1984,

Pass Two Areguments like this

<ItemTemplate>

<asp:LinkButtonID="lnkCreator"runat="server"

Text='<%# Eval ("fullname") %>'

CommandName="Select"

CommandArgument='<%# DataBinder.Eval(Container, "DataItem.lock", "{0}")+" "+ DataBinder.Eval(Container, "DataItem.ChangeRequest_No", "{0}")%>'OnCommand="lnkCreator_Command">

</asp:LinkButton>

</ItemTemplate>

in ASX.VB Page

ProtectedSub lnkCreator_Command(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.CommandEventArgs)

Dim strStringAsString = e.CommandArgument.ToString()

Dim resultArrayAsString() = strString.Split(" ")

EndSub

Regards,

Naveen

|||

How do I separate the two column values in the VB? I need both to be string values.

|||

On the ASPX page I used.

<asp:LinkButton ID="cmdDeleteJob" runat="server" CommandName="CancelJob" Text="Delete" CssClass="CommandButton" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Type_of_Service") +"|"+ DataBinder.Eval(Container.DataItem, "Other_Service") %>' OnClientClick="return confirm('Are you sure you want to delete this item?');"></asp:LinkButton>

On the VB side I used this, to get the values.

Dim delimStr As String = "|"

Dim delimiter As Char() = delimStr.ToCharArray()

Dim arguments As String() = Convert.ToString(e.CommandArgument).Split(delimiter)

Dim typeservice As Integer = Convert.ToInt32(arguments(0))

Dim Value2 As String = Convert.ToString(arguments(1))

Dim otherService As String = Value2

Monday, March 19, 2012

Deleting all but top record.

Hey Guys,

I have Performance Monitor running and storing the network usage to my MsSQL database, and this is done a few times a minute. I have a page that then shows show much of my bandwidth is being used. As you can gather, the database quickly starts filling up with hundrreds of records so I could do with a script that delete these records.
I cant simply delete all records because that would cause my webpage to fail so I need a way to delete all records apart from the latest one.
Wondering if anyone would know how I could do this?delete from tableRecords where recordid < (select max(recordid) from tablerecords)

Nick|||

Thank you, that works great.
I've just however noticed a potential problem. I understand that the RecordID can only go so high then will give errors. The thing is, the PerfMon has only been running a few hours and already it has produced 1800+ records. With your script I can just keep it as one record in the table, but the RecordID will get higher and higher. Im wondering what will happening if I let this run for a week or so, eventually it will stop working.
Anyone got any ideas?

|||Dont use an auto-identity field.
insert into table
select max(recordid) + 1 from table, [rest of fields]
Since you will only have one record in there at a time, this shouldnt hurt your performance.
Nick

Saturday, February 25, 2012

Delete subreport at runtime?

Is it possible to delete a subreport from a main form at run time? I am trying to find a work around for the inability to conditionaly format a page break.

I have a main form that has 10 subforms. Some of the subforms won't have any data (depending on the parameter values). When I export the main form to excel each subform needs to be in it's own excel tab. Obviously, I don't want a tab if there is no data.

Any suggestions?

Did you try setting the "NoRows" property on the subreport reportitem in the main report to e.g. =" " (one blank)

-- Robert

|||

Setting the no rows property to " " (one blank space) still brings back a blank page for that subreport.