.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

Unable to update records using IN clause

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
Hi, I've a common function as shown below: public int ExecuteNonQuery(string text, params IDataParameter[] parameters) { DbCommand command = new SqlCommand(); command.CommandText = text; command.CommandType = type; command.Connection = conn; command.Transaction = null; foreach (IDataParameter parameter in parameters) { command.Parameters.Add(parameter); } return command.ExecuteNonQuery(); } public IDataParameter CreateParameter(string name, object value) { if (!name.StartsWith("@")) name = "@" + name; DbParameter parameter = new SqlParameter(name, value); if (value == DBNull.Value) parameter.IsNullable = true; return parameter; }  When I want to update records in a table, I usually invoke as shwon below:// Assume you've a connection object IDataParameter param = conn.CreateParameter("vendor_id", vendorId); string query = "UPDATE table SET status=4 WHERE vendor_id = " + param.ParameterName; conn.ExecuteNonQuery(query, param); This code works fine. But when I'm trying to update multiple records using IN clause, it does not work. Can any one tell me how to do it using IN clause? I need to update all vendors ava

View Complete Post

More Related Resource Links

changing records frm control in update panel


i have a list box, a command button and a grid

when i click a particular record / or multiple records on the  list box and then cclick the command button the records r transferred 2 the grid

i also have custom paging, the paging shld ocur as many times i clcik the command button

i have used updatepanel with the command button in it so that partial postback ocurs or there is no page flicker ,

but when i use update panel i get teh records in the grid but custom page is not working . it has no affect even if the records are added

if i remove update panel the paging works properly

how do i manage it with update panel

Allow or deny roles to update, insert and delete records.

Hello, I have two roles "Admin" and "Basic". I also have a listview on the web page. My goal is that to make "Admin" role has the highest privilege to deal with records such as "insert", "update" and "delete". For the role "Basic", it only can update the records. Is there any sample code for that? Thanks.  

Unable to write anything when Update Progress Close

Hi,Acctually I have done lots of coding on Page_Load of a page which comming from other page. So for that i tried to use ModalPopupExtender. but problem is that its working fine for button but how can i use it for Page_Load.My scenario is:protected void Page_Load(object sender, EventArgs e)    {        PleaseWaitPopup.Show();        //Lots of code and queries;       PleaseWaitPopup.Close();          }  After too much googling i found one solution. which works but still problem is after closing ModalPopupExtender I am unable to write anything on page even i have removed StyleSheet:Current Code is as Follow:<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title> <link href="StyleSheet.css" rel="styles

Unable to update Work E-Mail in My Setting of Sharepoint 2010

Hey,   i am trying to update Work E-mail in My settings but it will not allow me to edit.   when i click on Edit Items then Attach file comes as user personal information   Please suggest me solution.   Regards, Sachin Phapale  

Update statement not updating records and returns no errors

I am running an Update statement against an SQL database on server 2008. The update runs but does not update the record, but returns no errors. The database is part of a commercial help desk package called TrackIt 8.5 which was just a fresh install on a new web server and a new sql server. The update is running from a web form we use to automatically create active directory accounts. After the account is created the web form closes out the work order in the Trackit db. This was working fine when the system was running on Server 2003 and SQL server 2005. Running Trackit version 7.02. The login use to access the database has full permissions to read and write to the database, just as it did on the old server which never had an issue updating. Odd thing is, if I log onto the SQL server and make a change to any single field in that record. I can then run the web form and it updates the record normally. All other update statements that are running on other databases are running fine. Anyone have any suggestions on what to check that may be causing this issue?

Unable to Set Control's Property After Update / PagePostBack


I'm trying to programmatically set the property of a control on my Form AFTER I've proccessed an update command using the FormView, but it's not working. 

In my example below, I have a basic FormView with only a TextBox and Label in its EditItemTemplate.  The FormView uses an AccessDataSource.  The TextBox is bound to the datasource, but the label is not.  What I'm trying to do is update the value in the TextBox (as well as its associated data stored in the database), and then change the Text property of the Label. (*Note: that I using the label purely as an example. The point is I can't see to set any control's property after an update).

I initally thought it had something to do with the "Page.IsPostBack", but even after trying to adjust my code for that, its still not working.

I've tried change the Text property during the Page.IsPostBack during Page_Load event. I've tried setting the Label's EnabledViewState property to True and to False. I've tried using the FormView's OnItemUpdating and OnItemUpdated events. I've tried using the DataSource's OnUpdating and OnUpdated events.

Nothing seems to work. Any suggestions?

Here's my sample code and Html:

<script language="VB" run

unable to update data to databse from grid view


I have two tables in my database

using "innerconnect" i have show table content in grid view as      INV_NO            INV_DT        DN_NO       DN_DT   LR_NO        LR_DT .

where LR_NO is null .

I want to update it from grid view plz help


here  DN_NO  and INV_NO are primary keys

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace amar
    public partial class Form2 : Form
        SqlConnection con;
        SqlDataAdapter da1,da2;
        SqlCommandBuilder cb;

Update records related to primary table in sql


HI All,

For example

I have 2 tables  Person and Person_Child.

In Person table i have columns

Id, PersonId,PersonName,PersonAdrress,PersonAge,RowId


rowid is identity


and in the person_child table--here parentrowid refers to parent table rowid and again rowid is identity here

Id, PersonId,PersonName,PersonAdrress,PersonAge,ParentRowid,RowId




I need to update the child table values as it is in parent tables where it is null.

I have to do for many tables.

Is there any way to do it dynamically.







Unable to update EntitySet


I have tables Events and Visitors with relation many-to-many. I had such error: Unable to update the EntitySet 'Events_has_Visitors' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

I found similar problem at the Weblog of Ken Cox but it doesn't solve my problem. When I set primary key at Events_has_Visitors table and update Entity Model for some reason relation becomes 0..1 to *, but if I'll delete primary key - relation will become many-to-many again. But still doesn't work.

Unable to Edit & Update user Profile Information

I Have a sharepoint Site.. I am trying to configure alter in the site..But Email ID are not available bel for all the users..I tried to Update the user Profile info by clicking the edit Item button in the user profile information.But it is not showing any editable content...It is just showing user NTlogin?This site is not connected to active directory.. We are adding users manually..How to update user details?

iis 7 IP Security using System.DirectoryServices : Unable to update


I used the below code to Set  IP Security from my vb.net Application.  It is working in IIS 6 (windows xp, and server 2003).

facing error in IIS 7.5 (windows7).

' Get the IIS object that holds the info for the default site.


Dim SecObj As Object = GetObject("IIS://LocalHost/W3SVC/1/Root/WebServerSCM")


' Get the IIsIPSecurity object.

Update with From clause


Hi, are there plans to support transact SQL for "Update table" with "From"-clause? With actual 3.5 an

update table1 set field=table2.field from table1 inner join table2 on table1.field=table2.field

doesn't work.

best regards, Toni

SSIS : Insert, Update, Delete records from destination table by comparing records in source table.


Requirement: Inse

rt, Update, Delete records from destination table by comparing records in source table.

Update: if records exist in both the table compare them, and update value in destination table if value is different.

Insert: if record doesn't exist in destination table, add new record in destination table.

Delete: if record exist in destination table but not in source table, delete record from destination table.

----> I have created an SSIS package that does all this task but in order to perform delete operation, I have to store all records of destination table into a temporary table.
And since it's not the most efficient way, I have created another SSIS package by using Lookup & conditional Splits
method, now it works fine with inserting and updating information but I am not sure on how to handle removing record operation!

I would really appreciate if you could help me with this.

(In order to archive inserting and deleting records, I have referred following thread!
http://sqlblog.com/blogs/andy_leonard/archive/2007/07/09/ssis-design-pattern-incremental-loads.aspx )

System.Windows.Forms.WebBrowser unable to update or change


I am using this WebBrowser component in a C# project.

I have declared and use "_wb" as shown below::

string httpcmd = @"https://...........";

System.Windows.Forms.WebBrowser _wb = new System.Windows.Forms.WebBrowser();                
_wb.ScriptErrorsSuppressed = false;                
Uri myuri = new Uri(httpcmd);
_wb.Url = myuri;
while (_wb.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete)


The above code in within a class.

Once my program uses the above code once, it then does seem possible to change.

i.e. After the first iteration, nothing changes each time the code is run.

The DocumentText property I reference stays the same once it is set.

It is like the URI is not even re-sent.

Only if I close the application and then re-run then the webbroweser will update as desired.

I have seen many references to this problem but have not been able to resolved it.

Can anyone suggest how to get this componet to reset or clear so it behaves like I have re-run the application?


Finding Records that were not deleted after update


I am trying to find a way to show the records that were not udpated after we run a Tscript that contains a large amount of update statements.  I dont know why the records are not being updated and is irrelevant.  We just need to see what records were NOT affected and I have been looking for 4 days and cant find anything.  The only thing that I found that was close was the OUTPUT statement, but that only allows us to see what WAS updated and there are so many records that taking the time to put it into Excel will be our very last resort!!

Someone please help me before I go out of my mind :(





Best way to update records with EF


Hey guys,

Using the EF on a project that I'm currently working on and was wondering which was the best method to use to update records in a table?

I figured I could just do something along the lines of declaring a new object, assigning a record to that object, update the values and then apply that object back in to the entity/table?

Keen to know how everyone else is doing it.


Unable to request Cumulative Update or any hotfix


I need to install the Feb 2010 CU for SharePoint 2007 (x86). This is KB978395. When following the link to request the hotfix, I am presented with the error message "The system is currently unavailable. Please try back later, or contact support..." I have tried accessing for several days. Have checked firewall settings, turned off anti-virus. Tried using Windows 7, Windows Server 2003, IE8, Firefox, Chrome - all with the same result. Although this particular update is what I need (to get a development VM to the same build number as a client's production system for troubleshooting a problem), ANY hotfix request returns the same error. I am in New Zealand, but have used this service fine in the past. The specific URL in question is http://support.microsoft.com/kb/978395 (but any hotfix request has the same problem). A search on the error message shows other people routinely have the same problem.

Any help would be appreciated.

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