ADO.NET :: .ExecuteNonQuery Not Performing Update?
Aug 4, 2010
I've got a routine that's supposed to be capturing data from an XML to a DataTable (which works fine), and then using that data to insert into MS SQL. I have no problems with the Inserting of records (via a different routine) but am struggling to update existing records - I'm not even getting any errors, and I can verify that the data is being assigned to the parameters.
Here's what I've got.
Shared Sub Sold(ByVal FullPath As String)
Dim SQLSold As String
Dim SC As New SqlConnection(CS)
SQLSold = "Update Properties SET Status = @Status, Price = @Price WHERE UniqueID = @UniqueID"
Dim DT As New DataTable
I have a table in a DB in which I need to perform the following operations:
1. Order the table using index A. 2. Traverse the table and do some calculations for every row. 3. Order the table using index B. 4. Traverse the table and do some calculations for every row. 5. Order the table using index C. 6. Traverse the table and do some calculations for every row.
As you can see, what I need is to process such a table several times depending upon a different index for every process. If I use a DataReader I can only traverse it one way and one time, I cannot apply another index and start from the beginning once again. What strategy should I use to achieve my goal? Is a DataTable a good choice?
I made a GridView application and adds a Delete icon into the GridView. When i compiled a code, it shows the GridView properly, but as i clicked on the Delete icon, it shows the following error: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified.
i am developing webservices.In that i want to maintain state information so that all WebMethods could be access only after Login.I have tried but getting problem.I am attaching my code.Any other alternative will also be welcomed.
a) SqlCommand.ExecuteNonQuery is used for update, insert and delete operations.
Besides the fact that by using ExecuteNonQuery instead of ExecuteReader we automatically know there won't be any query results returned, are there some other benefits/reasons why ExecuteNonQuery should be used?
b) Similarly, if we want a database operation to return a single value, we should use ExecuteScalar instead of ExecuteNonquery ,where with the latter result would be returned via SqlParameter. Is there any particular reason why we should prefer ExecuteScalar over ExecuteNonQuery?
I have created a utility method that contains some try/catches in it. In those try/catches I need to redirect the customer using an HttpResponse redirect. I can't seem to figure out how to do this outside a web project. This utility class is referenced from my ASP.NET web project and so I'm just abstracting out some of the code into this utility class so I no longer have the request object.
I know I can use HttpWebRequest object for a lot of web related request tasks outside a web project, but could not seem to get any redirect method there to use after putting in a using System.Net; in my utility class.
We need the ability to send out automatic emails when certain dates occur or when some business conditions are met. We are setting up this system to work with an existing ASP.NET website. I've had a chat with one of the other devs here and had a discussion of some of the issues.Things to note:All the information we need is already modelled in the ASP.NET websiteThere is some business-logic that is required for the email generation which is also in the website alreadyWe decided that the ideal solution was to have a separate executable that is scheduled to run overnight and do the processing and emailing. This solution has 2 main problems:If the website was updated (business logic or model) but the executable was accidentally missed then the executable could stop sending emails, or worse, be sending them based on outdated logic.We are hoping to use something like this to use UserControls to template the emails, which I don't believe is possible outside of an ASP.NET websiteThe first problem could have been avoided with build and deployment scripts (which we're looking into at the moment anyway), but I don't think we can get around the second problem.So the solution we decided on is to have an ASP.NET page that is called regularly by SSIS and to have that do a set amount of processing (say 30 seconds) and then return. I know an ASP.NET page is not the ideal place to be doing this kind of processing but this seems to best meet our requirements. We considered spawning a new thread (not from the worker pool) to do the processing but decided that if we did that we couldn't use the page returned to signify a success or failure. By processing within the page's life-cycle we can use the page content to give an indication of how the processing went.So the question is:re there
I'm trying to create a simple portfolio page. I have a list of thumbs and an image. When you click on a thumb, the image will change.
When a thumbnail is clicked, I'd like to have the image fade out, wait until the image is loaded, then fade back in. The problem I have right now is that some of the images are pretty big, so it fades out, then fades back in immediately, sometimes while the image is still loading.
I'd like to avoid using setTimeout, since sometimes an image will load faster or slower than the time I set.
Is there any way to perform traditional web based Upload SaveAs option with consoleapplication. I just want to call the saveAs option by passing the filename as argument need to be saved to the location.
I'm using telerik radgrid with some record rows , after updates one row from grid,where dispaly only that row.After click refresh button,all the records are view.
I have created a stored procedure that reset my tables' identity value. The store procedure works fine when I didrectly run it in my ms sql server 2008. It reset my table Identity value However, when I call it from my function reset, it returns -1, and does not reset my table identitity value. The function to restet my identity value is:
[Code]....
My stored procedure is
[Code]....
To call the the function:
Dim result As Integer = util.resetTableIdentity("myTable", "id", 60) util.print(result)
I got result is -1, and it does ot reset my table identity. Why? How to resove it?
I am observing a rather strange behavior. I have a procedure which selects a field from a matching record and returns it. The procedure works as expected returning proper values, when I execute the procedure from Visual Studio Server Explorer tab. The procedure is
[Code]....
This is being called from the DAL as follows:
[Code]....
The problem is if @ReturnValue is EAE then cmd.Parameter[outputParameterKey].Value is giving the value "E". If @ReturnValue is "Sassyboy" it is giving "S". why this behavior?
I need to write a single web page that checks the status of an SQL job, and allows the user to execute a new job if the job has a specific status.
I have the job status checking code working but have a problem when it comes to the execution of the next job. The problem is because as soon as ExecutNonQuery is run my code goes straight to the next line leaving SQL to do its own thing - therefore my UpdateProgress never shows. How do I get the UpdateProgress control is be aware that my Job is still running??
I also have a method called ReturnJobDetailStatus which I imagine I could use by continually checking it with a combination of the UpdateProgress control and a timer control? If so I cannot visualise how to achieve this?
I used this code it’s worked. But I want when Id exist then output any parameter equal 1 else 0. because I have two button Add and Continue.
CREATE PROCEDURE InsertName @Id INT = NULL @Name VARCHAR(50)= '' as BEGIN IF NOT EXISTS(SELECT Count(Id) FROM ParsonTable WHERE Id = @Id) OR @Id IS NULL
I'm learning about storing state in 'TempData' when performing the PRG (Post-Redirect-Get) pattern. It says TempData stores session state on the server. I'm wondering if this is safe or unsafe in a load-balanced server farm?
Are there precautions to be taken with TempData? Or can we happily program against it with abandon. Just wanting to avoid the frights we all got with the Session back in the day with ASP.NET of old.
I am trying to set up a POST from one aspx file to another progromatically. Inside the POST is a String of XML data which i have properly added to Server.HtmlEncode(). For some reason, when I grab it in my logs on the other page, it is showing with 3 question marks. I at first thought it was logging text i left somewhere, but have narrowed it down to a Encoding error of some sort because when i change the encoding it changes the character, and when I just put some text in there, i see it on the other side fine. i have tried UTF 8,UTF32,Unicode,ASCII... Can't seem to find the right combination. Can't find the UTF-16 when I use the Encoding object
Below is my Code:
[Code]....My Sending Debug log has the Extension xml coming out in HTML format correctly before POST. Below is just a piece of it[Code]....
Each virtual directory is configured on IIS6.0 as an application with own AppPool.
When redirecting authenticated user from dir1 to dir2 using response.redirect I lose authentication information for the user and the user is being redirected to the login page. This issue was not coming up with each app (dir1 and dir2) were configured under subdomain, ex: [URL]
I have resolved the issue by adding a machine key to the machine.config file.