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

Top 5 Contributors of the Month
Sandeep Singh
Post New Web Links

Update with OLE DB Command

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :Sql Server

Hi All,

I want to do an update using OLEDB command and I wrote the following code in the OLE DB Command component.

SET Column1= ?,
Column2= ?
WHERE Column3= ? AND Column2<> ?

However, it seems that I need to have as many distinct columns as the parameters. I have 4 parameters but 3 columns, how do I map them? PLease adise.

Thanks in  advance.

View Complete Post

More Related Resource Links

declarative #Bind doesn't bind in update command

I have a bunch of controls like the following in the EditItemTemplate of a ListView, with LINQDataSource:<asp:TextBox ID="Email" CausesValidation="true" EnableViewState="False" Font-Bold="false" Text='<%#Bind("Email")%>' BackColor="#FFFFFF" Enabled="true" TabIndex="50" runat="server" /> I'm curious to know why the database won't update on the click of the Update button:<asp:Button ID="btnUpdate" CommandName="Update" Text="Update" UseSubmitBehavior="False" TabIndex="170" runat="server" /> According to all I've read, the above code should be sufficient. Since CommandName is set to Update, it would seem that no code-behind is necessary.

SQL Update command on button click

Hello!I don't know what is the problem with my code. SQL statement is good (I checked it outside of the application) but for some reason it doesn't update the data.Let me explain a bit better. I have a web form which is supposed to be used for editing data in textboxes and on button click the data should be updated via SQL query.public partial class Administracija_Clanak : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string ClanakID = Page.Request.QueryString["idClanak"]; String connString = WebConfigurationManager.ConnectionStrings["CMS"].ToString(); SqlConnection conn = new SqlConnection(connString); conn.Open(); using (SqlCommand command = new SqlCommand("SELECT Clanak.* , Kategorije.naziv FROM Clanak Clanak INNER JOIN Kategorije ON Clanak.idKategorije = Kategorije.idKategorija WHERE Clanak.idClanak='" + ClanakID + "'", conn)) { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { txtIDClanak.Text = reader.GetInt32(0).ToString(); ddlKategorija.Text = reader.GetInt32(1).ToString(); txtNaslov.Text = reader.GetString(2).ToString(); txtAutor.Text = reader.GetString(4).ToString(); txtSadrzaj.Content = re

Update Command!

Hello,I'm using DetailsView and also used the code below to allow the user to (Edit and Update his or her info):UPDATE DatabaseTable SET      Column1 = @Column1,     Column2 = @Column2,      Column3 = @Column3 WHERE UserId = @UserIdIn the Datasource (Update query property).I have no error during debugging or using the web page, The only problem i have is:When i insert a new value and hit (Update), The same old value shows and no new values saved? Thanks in advance.

OLE DB Command Transfornmation-- Update

Can any one help me on OLEDB Command Transformation... Below is the Scenario.. Table1 Structure: EMPID Name Location 111 xxx   Table2 Structure: EMPID Location 111 YYY When EMPID Matching in Both table, I just wat to update the Location detail from Table 2 with the help of OLEDB Command Transformation.... I did this one... It's executing perfectly... and showing like 1 row's transferred... While Checking a table1 no updation Occurs...        

Multiple sql server update statments in SSIS OLE DB Command


Is it possible to issue multiple sql server update statements in SSIS OLE DB Command?


I Tried the following with no luck


update table1 set column1 = 1


update table2 set column1 = 1

GridView Update Command


I am trying to use an Update Command within my GridView.  I need to find the "FindControl" for the Edit Command textboxes.

Ie. When the user clicks the Edit button, the row is populated with dropdown boxes, textboxes, etc for editting. Then when the user clicks on Update (button) and the GridView1_RowCommand function is activated with 'if (e.CommandName == "Update")' statement with my FindControl. etc. and my sql UPDATE command statements are used.  How do I convert my FooterRow info to my Edit FINDCONTROL info?

This is what I have:

protected void GridView11_RowCommand(Object sender, GridViewCommandEventArgs e)

if (e.CommandName == "Update")


GridViewRow footer = GridView1.FooterRow;
            ddCityXXX = footer.FindControl("ddCityXXXInsert") as DropDownList;
            ddOvernightLSN = footer.FindControl("ddOvernightLSNInsert") as DropDownList;
            txtHotelName = footer.FindControl("txtHotelNameInsert") as TextBox;
            txtHotelAdd = footer.FindControl("txtHotelAddI") as TextBox;
            txtHotelCity = footer.FindControl("txtHotelCityI") as TextBox;
            txtHotelState = footer.

Microsoft Matrix Framework DataGrid - Update Command - Convert empty strings to NULL



we have a AutoGenerateColumns-enabled WmxDataGrid in which we are able to update table rows in a DataBase connected with a SqlDataSource.

Each time we clear a field an empty string is written to the database where we want to write DBNull values.

At the moment we generate the update string via UPDATE... SET.. and the SQL Server function NULLIF(value, '').

Works proper but when I want to add the values to e.NewValues in BeginUpdate event I'm not able to read the values from the auto generated text boxes.

How do I do that? Is there an easier way to automatically convert empty strings to NULL values?


Gridview - Update with Dynamic SELECT Command?


Hi All...

We created a GridView-based webform with Update using the design wizards - very nice and it works great.  But then we wanted to the ability to create the SELECT command dynamically based on other controls on the page.  We added something like the following to Page_Load()...

            SqlDataSource1.SelectCommand = "SELECT [StationId], [IP] FROM [Stations]";

The GridView populates normally, but the Update no longer works.  It changes the "Edit" link to "Update", gives the user the edit boxes, but when "Update" is clicked it never seems to write the new data to the database.  No error - it just doesnt work...

Any thoughts?  How can we change the SELECT command (and Connection String) dymamically and still retain the Update functionality?

Many thanks - Curt.  Code follows...

    protected void Page_Load(object sender, EventArgs e)
        //  Doesn't work with or without this conditional
        //if (!IsCallback)
            SqlDataSource1.SelectCommand = "SELECT [StationId], [IP] FROM [Stations]";

update fomr OLEDB command goes wrong


Hello all,

I use a conditinal split to check if records exists and have changed. Is so the dataflow goes to a storedprocedure to update the table. The stranges thing happens, all the records got updated with the same change, so for instance all the birthdates of users are the same after the update. It seems like the update commande holds the same values for the variables, when i look with a dataviewer I see different data then the data inserted. Anyone a clue what this can be?

within the oldb command I cal the stored procedure as "exec spUpdateall ?,?,?,?,?,?,?,?,?,?,?,?,?,?"
Where the questionmarks are the ammount of variables.

Thank you


update SharePoint list with data from infopath form using the Command Prompt or similar


i have a InfoPath form that is updating a SharePoint list when it is submitted. Now i added some extra Fields to the Sharepoint List. All these new Fields are empty till I open the InfoPath form and hit the submit buttion again.

Is there a way to update all the empty fields from the old entrys I made.

My first Idea was to search for a Powershell Solution but unfortunately I am using Windows Server 2003 R2, Sharepoint 2007 and IndoPath 2007.

Hopefully someone can Help ;)

thanking you in anticipation

Error when attempting to Update Farm Credentials using stsadm command



When executing the following command


stsadm -o updatefarmcredentials -userlogin [login name] -password [password]


I get the following error


Error updating the administration application pool credentials.


Need help in updating my farm credentials and the only tool available generates a vague, non descript error.  Any help/suggestions would be appreciated.


As a result of not being able to update the credentials I get the error message that the service is unavailable when launching the SharePoint Configuration Database.

generation id in update command


SQL Server 2008. Please, tell me how it is possible to generate row_id for existing table if all values for rowid is null. I try such query:

UPDATE [tempdb].[dbo].[Products]
SET row_id=1+(select MAX(ISNULL(row_id,0)) from [tempdb].[dbo].[Products] P 
      where P.productid = productid)
But it makes all records equal. What is an algorithm of my action?

Catch update command - DetailsView



Is it possible to catch the exact command which is passed to the SQL Server (os other connected database) at the end of "ItemUpdating" event?

note: the command with all the paramaters inserted already, e.g.: "EDIT table1 SET field1 = 2, field2='this is a string WHERE (id=123)"



Slow but simple SQL Update command. I don't think its the code.

Hello Community,

The following is a very simple SQL statement that is running very slow, about 1-2 seconds. I have very complex Updates in the Assembly. This is without a doubt the most basic and runs the slowest. Others, as expected, feel instant. This one, hangs.

It is also the only SQL in the assembly that does not use cmd.Parameters.Add... code. So I removed the date update, I also removed the row self reference and the code, then i removed the WHERE .. broken all the way down to   "UPDATE vrxdata SET AccessCount=1" Still slow.

If you have questions about recordid:

[recordid] [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL

Nothing else is going on in the software for this to happen. Software is idle, button_click to execute this code and wait...        


stored procedure is not getting invoked on update command of grid view


Hello everybody!

In my project I am using a grid view to display data from multiple tables and I want to update that data on clicking edit button.

For selecting data I am using custom select statement, but for updating I have created a stored procedure which should update two different tables.


But when I click on update , it's not executing the stored procedure.


here is the code snippet of sqldatasource:-

<asp:SqlDataSource ID="SqlDataSource1" runat="server"  UpdateCommand="editEmployeeInfo" UpdateCommandType="StoredProcedure">


                    <asp:Parameter Name="empId" Type="Int32" />

                    <asp:Parameter Name="name" Type="String" />

                    <asp:Parameter Name="address1" Type="String" />

                    <asp:Parameter Name="address2" Type="String" />

                    <asp:Parameter Name="telNo" Type="String" />


ASP.Net Gridview Edit Update Cancel Commands

In ASP.Net 2.0, GridView Control also provides the functionality to edit and update the data retrieved from the database using CommandField template. You can cancel the action using Cancel Command of the CommandField. GridView consists of events that can be used to perform the actions like edit, update and cancel upon the Data items displayed in the ASP.Net GridView Data Control.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.
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