.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

here is trigger if exist then update else inser but not working properly for bulk update(10 or 15 ro

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :Sql Server


i have a trigger as follows



TRIGGER [ table_detail_insert_update]








View Complete Post

More Related Resource Links

Update panel with async trigger not working


 I have following code and when I select from my drop down list the progress controls do not show and my grdiview is not being filled either. If I leave out the update panel from my code things are working fine.

  <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional"  runat="server">
                 <asp:AsyncPostBackTrigger ControlID = "TabContainer1$TabPanel1$DropDownList3" EventName = "SelectedIndexChanged" />
                 <asp:Label ID="lblText" runat="server" Text="Loading data ......"></asp:Label>
                 <asp:Image ID="img1" runat="server" src="Icons/ajax-Loader.gif" /> 
<cc1:TabContainer ID="TabContainer1" runat="server" Height="20px" ActiveTabIndex="0">
                    <%--OnActiveTabChanged="TabContainer1_ActiveTabChanged" AutoPostBack="true">-

After Update trigger for a record which does not exist in table.


Hi Everyone,

I have a update query which sometimes results in no row updated (i.e. 0 rows updated),

I want to apply after update trigger on it , if update results in 0 row affected then insert that record,

I have written following trigger for it,

ALTER TRIGGER [dbo].[table1]

   ON  [dbo].[table1]





            SET NOCOUNT ON;

update/delete not working on server only


my aspx page works in VWD, and everything works on the server EXCEPT update and delete sql functions. any ideas?


execute update timedout expires , table with trigger due to recovery of database


I have table A in database A  , in table A i have trigger to insert record to database B table A, each update and insert of database A -table A, triiger fire and insert record in database B table A, when i try to update some times asp.net application gives error

"Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

and then error log says System.Data.SqlClient.SqlException: Database 'database B is being recovered. Waiting until recovery is finished.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean ret

Trying to set update panel trigger programmatically


 I have a recursive sub that finds a dropdown list and sets up an AsyncPostbackTrigger for an update panel. I have tried calling this sub both from page_init and page_load 

If the dropdownlist is within the update panel, eveything works fine. If the dropdown list is not in the updatepanel I get error

A control with ID 'ddlPersonFilter' could not be found for the trigger in UpdatePanel 'up1'. In both cases the sub does find the dropdown list and executes the code to set up the trigger. Thanks for your help.

    Private Sub SetUpdatePanelTrigger(ByVal oControl As Control)
        For Each ctrl As Control In oControl.Controls
            If TypeOf ctrl Is DropDownList Then
                If CType(ctrl, DropDownList).ID = "ddlPersonFilter" Then
                    Dim thisddl As New DropDownList
                    Dim thistrigger As New AsyncPostBackTrigger
                    thisddl = ctrl
                    thistrigger.EventName = "SelectedIndexChanged"
                    thistrigger.ControlID = thisddl.ID
                    Exit Sub
                End If
                If ctrl.HasControls Then
                End If
            End If

doing bulk update

Hello Everyone, I have a gridview. users can update the database using this gridview. There are about 10 columns and 60 rows in this gridview and once the user makes the changes to a particular row, there is an update button on that row and user can click that button to update the changes that he/she made. My boss wants to remove the update button from each row and put the button at the bottom of the gridview. he says that I will make the changes to whatever rows, I want to make the changes to and then hit the update button that is at the bottom of the grid and it should make the changes to all the rows in the database. I can accomplish this by opening the database coonetion and making a call to the database several times and updating row one by one or I can do all bulk insert. how can I acheive this bulk insert because the other option is quite expensive. Please let me know if anyone has any ideas. Thanks in advance  

jquery is not working in asp.net panel and/or update panel ? need help

I have 3 panels on single .aspx page and depending on condition required panel is displayed . Default panel is panel 1 .  I have created a image gallery which displays thumbnails of various images and when I hover on that image its preview is displayed. I have put the code for this image gallery in 2nd panel, it displays thumbnails but on hover preview is not displayed. but  if I somehow make postback then it works. And I place the same code in !st panel it works ? Can anyone tell me whats wrong with my code? Regards, anas anjaria I have 3 panels on single .aspx page and depending on condition required panel is displayed . Default panel is panel 1 . I have created a image gallery which displays thumbnails of various images and when I hover on that image its preview is displayed.I have put the code for this image gallery in 2nd panel, it displays thumbnails but on hover preview is not displayed. but  if I somehow make postback then it works.<div> /* PAnel 1*/ <asp:UpdatePanel ID="updpnl2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="pnl2" runat="server" Visible="false"> /*other coding stuff*/ <div id="wrap"> <div id="styles-table"> <div id="styles-wrap"&g

File Upload Control is not working in Update Panel

hi friend... i am using update panel... in one of my aspx page (ASP.NET 2.0)there is a file upload control in update panel which is used to upload company logo on server..when i remove the update panel.. than file upload is working properly..but when i again place an update panel then file upload control is not working and its giving me error.. in likeIf String.IsNullOrEmpty(fldLogo.PostedFile.FileName.ToString) Then                 as object reference not set to an instance of an object... can any body help me ?any idea ??  

Trigger without UPdate,INSERT and DELETE


I have SQL SERVER 2005 and I have a table with a Cloumn DATETIME data Type,

I want to ceate a trigger that checks the table rows and delete the record (s) when it has (DATETIME colume value - today date()) >20  days.

Is it possible to write a trigger for that? 

I am new to SQL Server and trigger.




How to bulk update?


hi friends,

i have declared thsi tabel:

	declare @tbl_ans table ( a_idx int, AnsText nvarchar(max), is_correct bit, is_active int)

a_idx is not an indentity column

the table has data

then i have declared thsi:

			declare @val table (idx int, a_text nvarchar(max))

idx is not an identity column, te tbale @val is store the id values and a_text1 values of Answers table after inserting values to teh answers table

There is teh third table Answers of the following structure:

a_idx int, // this i an indentity column 

a_text1 nvarchar(100), 

upt_date datetime, 

rversion timestamp

In my Previouose thread i have written the insert statement for this

update panel not working in live



I have a button that updates a datagrid that is in an update panel and everything works swimmingly in the dev area but when i publish it it just doesnt work.

appart from that everything else on the page works as normal

anyone have any ideas? 


thanks in advance

Color Box Jquery Not Working in Update Panel After the Initial Postback


Hi Guys,

I have an UpdatePane that contains a Listview


		<asp:LinkButton ID="lnkName" runat="server" CommandArgument='<%# Container.DisplayIndex %>'
            CommandName="SelectedRow" Text='<%# Eval("Name") %>' Class="info" Rel='<%# Eval("ID") %>' />

This linkButton will serves as the trigger to call my color box jquery. Function stated below

 <script src="script/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="script/jquery.colorbox-min.js" type="text/javascript"> </script>
    <script type="text/javascript">

        $(document).ready(function() {

            $("a.info").click(function() {

                $(this).attr("href", "EmployeeDirectoryDetail.aspx?id=" + $(this).attr("rel"));
                $(this).colorbox({ height: "200p

Publishin page layout, that add/update values in a metadata of the page not working


We have custom control on Publishin page layout, that add/update values in a metadata of the page. Code is written in 'Button click' event that update/add new values to the metadata. Following is the code snippet, which is working fine in Stage and Acceptance servers. Publishin page doesn't update Draft version with SPListItem.SystemUpdate instead it updates to last published major version.

currentPublishingPage = PublishingPage.GetPubl

GriedView Update is not working


Hi all,

Here is my asp and the code behind code. When I click edit and enter a new weight value, the system does not maintain that value, but displays back the original one (if I press enter I see that hapening or through debug).

What am I missing?

Thank you

protected SqlDataSource GetSqlDataSource()


            SqlDataSource dsL = new SqlDataSource();

            dsL.ID = "ds1";


            // You can use this utility class to get the connection string


            dsL.ConnectionString = DBUtility.GetConnectionString();


            // Set the sqldatasource commands like this:


            dsL.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;


            dsL.SelectCommand = "GetGrossOrganforUpdt";  //GetGrossOrgan


SQL Trigger INSERT, UPDATE table name (inserted updated)

I am trying to make a trigger for INSERT, UPDATE.  For INSERT you get a table named inserted that you can use, and for UPDATE you get updated.  But what is the name if you doing a trigger for both?

oracle not working insert update and search


 here is my code where im doing mistake

here is my class1 code

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OracleClient
Public Class Class1
Public Shared conn As New OracleClient.OracleConnection(ConfigurationManager.ConnectionStrings("MOH_String").ConnectionString)
    Public Shared cmd As New OracleCommand
    Public Shared da As New OracleDataAdapter(cmd)
    Public Shared pr As New Parameter
    Public Shared dr As OracleDataReader

    Public Shared Function GetData(ByVal strQuery As String) As DataTable
        Dim dt As New DataTable
        Dim cmd As New OracleCommand(strQuery, conn)
        cmd.CommandType = CommandType.Text
            da.SelectCommand = cmd
        Catch ex As Exception
            Return dt
        End Try
        Return dt
    End Function

 Public Shared Function SpInsertUpdateDelete(ByVal SpName As String, ByVal cmd As OracleCommand) As DataTable
        cmd.CommandText = SpName
        cmd.Connection = conn
        cmd.CommandType = CommandType.StoredProcedure

        Catch ex As Exception
            Return No

Datagrid Link button within the Update panel events are not working



I have a datagrid with linkbutton within the datagrid.   When i click on link button there is no response.   I have tried in different ways like
1.   after data binding to the datagrid
2. AsyncPostBackTrigger ControlID="lnk1" EventName="Tick"

can any one please tell me How to fire the linkbutton

Thanks & Regards,

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend