C# - Alternative To Firing A Stored Procedure 368 Times To Update The Database?

Jul 19, 2010

I'm working on a .NET component that gets a set of data from the database, performs some business logic on that set of data, and then updates single records in the database via a stored procedure that looks something like spUpdateOrderDetailDiscountedItem.

For small sets of data, this isn't a problem, but when I had a very large set of data that required an iteration of 368 stored proc calls to update the records in the database, I realized I had a problem. A senior dev looked at my stored proc code and said it looked fine, but now I'd like to explore a better method for sending "batch" data to the database.

What options do I have for updating the database in batch? Is this possible with stored procs? What other options do I have? I won't have the option of installing a full-fledged ORM,Additional Background Info:Our current data access model was built 5 years ago and all calls to the db currently get executed via modular/static functions with names like ExecQuery and GetDataTable. I'm not certain that I'm required to stay within that model, but I'd have to provide a very good justification for going outside of our current DAL to get to the DB.

Also worth noting, I'm fairly new when it comes to CRUD operations and the database. I much prefer to play/work in the .NET side of code, but the data has to be stored somewhere, right?

[Code]...

View 9 Replies


ADVERTISEMENT

SqlCommand Calling A SQL Server Stored Procedure Times Out?

Jun 14, 2012

I've got a conversion utility that basically copies values from one table to another. It's worked great for a while, but I've run into a strange issue with one customer. They got through 1.5 million records with the utility but now it is completely halted.When calling a stored procedure from VB.Net, it just hangs until the SqlCommand times out.Calling the same sproc from Management Studio executes instantly. My VB.Net code for the SqlCommand is below (insertConn is defined and opened earlier, dr is a SqlDataReader that has been populated in a previous step from completely different SqlConnection and SqlCommand instances):

Dim conn As New SqlConnection("connection string here")
Dim insertConn As New SqlConnection("connection string here")
Dim dr As SqlDataReader = Nothing

[code]......

View 2 Replies

Asp.net - Insert And Update With XML In Stored Procedure

Oct 20, 2011

I need some help in using a stored procedure in my case below: I have a table with a single XML column which takes in fields VoucherCode and Quantity, the data in SQL xml column looks like this:

<CampaignVoucher xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" VoucherCode="Vouch001" Quantity="2" />

The below method will call my stored procedure to check if a particular voucher exist based on my voucher code and then either add a new row or update an existing voucher in my gridview:

Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click
Dim dbCommand As DbCommand = Nothing

[Code].....

View 1 Replies

Update SQL Table Using Stored Procedure

Jun 11, 2010

I'm using a stored procedure, but am receiving a "Procedure sp_OrderTracking_Update_UpdateItem has no parameters and arguments were supplied" error. Here is my stored procedure:

[Code]...

View 7 Replies

Use A Stored Procedure To Update An Identity Column?

Jul 15, 2011

I don't understand this code (listed below). this code attempts to modify the products table . It creates an update, delete and insert command. I don't understand where it gets the data values from. What I mean is that, how does it know which record to delete. there in no input box or textbox from where it can get the product ID, which would identify which record to delete.[code]...

View 1 Replies

Go Into Update Mode After Inserting A New Record With A Stored Procedure?

Jul 7, 2009

<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Partial Class _Default</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x:

[code]....

View 9 Replies

Stored Procedure Group Invoice Records And Update Accordingly

Jun 12, 2011

I am a Newbie using SQL server and vb.net in VS2010. I am re-writing an existing application which is written in an old programming language. I have a table with invoice records waiting to be assigned an invoice number and invoice date. I have two ways of updating these records , the first way is the user manually selects which records/rows to be updated for a specific customer account number. This all works fine.

I am trying to write a stored proc which goes through all un-invoiced records (i.e., invoice number = blank) , it is to group records/rows by account number and assign next invoice number (which I already have astroed proc to fetch) and then when the account number changes to move onto the next batch of records for the next account.

View 2 Replies

Update With SQL Generating This Error: Could Not Find Stored Procedure 'False'?

Jan 5, 2012

Update with SQL Generating this Error: Could not find stored procedure 'False'. I'm not using a stored procedure i'm doing a simple update

Dim cmd As New SqlCommand
Dim connconnection As New SqlConnection(conn)
connconnection.Open()

[code].....

View 2 Replies

Call A Stored Procedure From Sql Server Which Work With A Stored Procedure

Sep 11, 2009

The store procedure which give me the information I need is:

USE [UCSMIS]
GO
SET ANSI_NULLS ON

[Code].....

When I try to add it to my report it gives an error, is it because of the temp table and how should I go about it?

View 2 Replies

Dataset / Database Stored Procedure

Oct 21, 2010

I am attempting to create a tier application. Im wondering which approach would be better to take on. Should i have stored procedures on the database and then call these from my Data Access Layer (this is when you right click your dataset and add a table adapter, select existing stored procedures or create the entire query in my Dataset under TableAdapter?

My reason for asking is because my Stored procedures are created to insert and update in one command (by using an If statement), but saw the other approach recently. Any reason for one over the other?

View 2 Replies

Adding Few Rows To The Database Using Some Stored Procedure?

Jun 2, 2011

I am using visual basic express 2008 . and i am adding few rows to the database using some stored procedure. it is working fine. after adding the row i am displaying in a grid using dataset . fine.but when i close the program and reopen the program i can't see any rows in the database..

I don't know the problem.this is my code to create a procedure.

Code:
ALTER PROCEDURE AddNewStaff
@SName varchar(50),
@DOJ date,

[Code]....

View 1 Replies

Sql - Getting Parameter For A Stored Procedure Inside Another Stored Procedure

Aug 29, 2011

I have a stored procedure to update a table, but needs a couple of values from another table.

the first two selects get the value from the table and then are used in the update statement.

The select statments:

Select @iStatusDropDownValueID = iDropDownValueID
From DropDownValue
Inner Join DropDownValueType On DropDownValue.iDropDownValueTypeID =

[Code].....

First, the values that are retrieved by the first two select statements are always the same. So they could be passed in by the code itself. I don't know that this will speed things up at all, just make the entire stored procedure better and easier to read.

Second, if the "Value Name" should change this store procedure will break (which is possible, but not often).

I am looking for any insight into the Best Practices for this situation.

View 2 Replies

.net - What Stored Procedure Is Crystal Reports Using To Connect To Database

Nov 25, 2010

I'm trying to make alterations to an existing Crystal Report form in a VB.net project I've inherited, and it's my first time using Crystal Reports. For clarity, I'm using Crystal Reports under Visual Studio 2010, not the standalone Crystal Reports.I've had a good go at looking through all the functions and variables listed in the CR Designer, and can't find what stored procedure is being used to call for data.

View 1 Replies

Asp.net - Insert Datatable Into A Database Table From A Stored Procedure?

Feb 29, 2012

I have a datatable with some rows I need to insert that datatable in to database using a stored procedure.

For Each row As DataRow In dt.Rows
cmd.Parameters.Add(New MySqlParameter("@DOWNLOAD_ID", dt.Rows(0)("DOWNLOAD_ID").ToString()))
cmd.Parameters.Add(New MySqlParameter("@FINALY_FIELDCODE", dt.Rows(0)("FINALY_FIELDCODE").ToString().Replace("|", "").ToString()))[code]....

When i do this I got an exception {"Parameter '@DOWNLOAD_ID' has already been defined."} How to get rid of this exception and can we insert the datatable with out for loop.

View 1 Replies

DB/Reporting :: DataGridView Back To SQL Database Through Stored Procedure

Feb 18, 2009

I have an app written in vb2005 that allows users to search a sql database for a store name. Once a store is selected, it then presents the user with 12 different tabs, each with a DataGridView showing various bits of info about the store. It's a large and convoluted database, so I'm using stored proceedures to pull the data for each tab. Here's a sample of one of the subs that populates the tabs.[code...]

Now, this works just fine to populate the grids on the tabs, and the same code is copied into each of the subs that fill the grids (changing the stored proc, parameter and grid names, of course). The problem I'm having is how to move changes made to the data in the grid back into the database.

I have stored procs that do this (and the procs do work), I just can't seem to figure out how to trigger the stored proc when the user makes a change.

If it matters, there is only a grid on each tab, I did not use a binding source as I am trying to keep an abstraction layer between the data and the app. I did create a dataset, which is how I gain access to the stored procs, but I left the grids unbound and (as seen in my code) bind them at run time.

View 2 Replies

Insert A Value To A Column In A Table In Database Using .Net And Stored Procedure?

Jun 1, 2011

i am new to stored procedure and VB.Net, i am trying to insert a value to a column in a table in my database using VB.Net and Stored procedure Here's the procedure:

1. A user will input a value to a textbox, for example lastname.

2. When the user click the save button, the button will call the stored procedure.

Here's my code in stored procedure:

[Code]...

View 1 Replies

VB - Database File - Create The New Stored Procedure 'getEmployees'

May 4, 2010

I have completed the coding for this assignment but have a few errors that I cannot figure out. I did create the new stored procedure 'getEmployees'

Error1Type 'PubsDataSetTableAdapters.getEmployeesTableAdapter' is not defined
Error2Type 'PubsDataSetTableAdapters.getEmployeesTableAdapter' is not defined.
Error3'getEmployees' is not a member of 'CIT263Lab5.PubsDataSet'.

View 1 Replies

DB/Reporting :: Stored Procedure On An Oracle Database Called : GET_HVE_PACKAGE_VERSIONS

May 29, 2008

I have a stored procedure on an oracle database called : GET_HVE_PACKAGE_VERSIONS This basically calls versions of PLSQL packages as stores the versions into a table. I am having big problems trying to call this procedure. I have tried everything. I am currently able to create and update etc etc using the executeNonQuery method and I thought that I would be able to call a procedure them same way, obviously not

the whole project depends on me being able to call procedures against the database.

[Code]...

View 5 Replies

EditingControlShowing Events Firing Multiple Times?

Feb 24, 2009

I have a DGV in VB.Net 2008 connected to an Access DB table. The DGV is not Read Only, but is full of read-only columns except for one, which contains a combo box. The combo box allows the user to select an outcome for that particular row, and then the program copies in a pre calculated value into the "Profit" column depending upon the item selected in the combobox. Then the user hits the Save button and the DB updates (currently via SQL methods in the XSD).

Easy enough so far.

Here is the code.

Private Sub DGUserBets_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DGUserBets.EditingControlShowing

[Code]....

The problem I have is that it would seem that if a user selects the desired outcome from the combobox but does NOT hit Enter, and simply mouses on to a different combobox to again select the outcome for a different row, the first eventhandler is not disconnected and thus the events fire multiple times. This then causes various default MsgBox errors and brings up problems when the user tries to commit all changes to the DB/exit program etc etc.

What do I need to do? Do I need to .EndEdit somewhere appropriate to force the row to save the changes? And where should I call this?

View 5 Replies

Events - SelectedIndexChanged Firing Multiple Times

Apr 25, 2012

I am trying to programmatically add an unspecified amount of new UserControls to a form. One will be added every time an entry is selected in a ComboBox contained within the UserControl. Problem is, the SelectedIndexChanged event fires completely erratically. Sometimes twice, sometimes 3 times, etc., but never just once. No matter how many times I set the combobox's SelectedIndex to -1, it fires at least once with a SelectedIndex of 0. Sometimes the Itemselected event fires multiple times inbetween SelectedIndexChanged events.

InvoiceEntry.vb snippet:
Public Event ItemSelected As EventHandler
Private Sub cboItem_SelectedIndexChanged(sender As System.Object, _
e As System.EventArgs) Handles cboItem.SelectedIndexChanged
RaiseEvent ItemSelected(Me, EventArgs.Empty)
End Sub
[Code] .....

View 1 Replies

Prevent A Sub / Function From Firing Multiple Times On The Same Event?

Apr 1, 2009

I'm trying to prevent a sub / function from firing multiple times on the same event.My app is for handling inbound phone calls (tapi).The app is supposed to route calls based on the callerid number.

aircode below:

Code:

Private Sub OnNewCall(ByVal sender As Object, ByVal e As NewCallEventArgs) Handles tapiManager.NewCall
if newcall.callerid = "5551001" then
redirect(newcall)

[code]....

If callA.callerid = "5551001" then redirect(callA)but, once it is redirected to the new extension, do not then grab the call from the new extension and try to redirect again (resulting in infinite loop).I realize I could use an integer as a counter, but the problem is, I might actually get more than 1 call at the same time from the same callerid number. And, all the calls would need to be redirected (once).the calls do have properties like (which are unique identifiers to each call):

Code:

phcall.id and phcall.hashcode

I'm thinking I need to put that unique id into a temp var / array to run a check against to see if it has been redirected, if it has then skip, if it has not then redirect.The app would run 24x7, and I don't want the temp var / array to get too big, and would want to have it clean automatically (up on a timer maybe?)(I'm guessing it would be a dynamically growing array.)

View 10 Replies

Web Browser Document Completed Event Firing Several Times

Apr 30, 2011

url..I tried to change the combo box value and save the webpage data in string and finally extract my desired data. It works but unfortunately when the combo box value is changed it takes some times for webpage to update.

View 1 Replies

Edit / Update Image Stored In Access Database?

Jun 9, 2012

I have a small application that (Adds, retrieves and deletes) info from/into access 2007 database file.I'm using Oledb (Online Mode) .I use this code to save new record to the database file[code]...

View 11 Replies

Devexpress Gridview Delete Event Is Firing Multiple Times

Jul 21, 2010

I have a Devexpress Gridview that is linked to a delete, fetch and update stored procedure. The problem I am having is that when I run my program, select a row in the grid and press delete it fires the event multiple times. Specifically it deletes the selected row and then I re-fetch the data so the focus returns to the first row. Which is what I want.

Unfortunately it starts at the beginning of my list and goes down it row by row deleting each row it comes to. It then continues several more times after the rows are deleted. I know this because for each deleted row it asks me if I want to delete it. If I say no then the rows appear to disappear until I manually refresh it after the deleting is done. To make this even more random the second row always reappears after I manually refresh the grid.

[Code]...

View 1 Replies

.net - Cannot Call Stored Procedure From Code Which Works On Direct Call To Database

May 17, 2011

I connected to the Informix server using RazorSQL, created a stored procedure and tested it, getting the expected answer, so the procedure exists in the database in some form.

I then run the following code:

If ConnectToInformix() Then
Dim cmd As New IfxCommand("dc_routeHasOutstandingQuantity", conn)
cmd.CommandType = CommandType.StoredProcedure

[Code]....

This error does not occur when calling the stored procedure from a live SQL connection.

View 1 Replies

Does VB Allow A MS Access Database DataSet Create A Stored Procedure Or Will It Only Allow SQL Database DataSet Create SP

Oct 9, 2009

does VBasic allow a MS Access Database DataSet create a Stored Procedure or will it only allow SQL Database DataSet create SP...

View 4 Replies

Sql Server - Why Can Only Execute A Stored Procedures Two Times

Nov 24, 2009

In my VB.NET code I construct a ODBC.COMMAND to call a stored procedure that eliminates a record from table in SQLSERVER 2008, I use this code in a FOR NEXT loop, it may contain 1 to 20 records_ID to pass to stored procedures to delete the records.

This code work well for several months, but since the last compilation it only deletes the first 2 records.

In debug mode in VS 2008 IDE works fine.

VB.NET CODE
''' <summary>
''' DELETE CANCELED CUSTOMER ORDERS
''' </summary>

[Code]....

View 2 Replies

.net - Using A Stored Procedure

Sep 7, 2009

I want use a stored procedure in my project but I have no idea about it. Please could you tell me a little bit about how to use I can use one in my vb.net application ?

View 2 Replies

How Stored Procedure Run

Dec 22, 2011

I have noticed the following but unable to understand why.Whenever a procedure is called in .net it takes more time than when it is called subsequently.Even if a procedure is called after some interval it takes more time than it takes if it is called quite frequently. i am not asking about sql query or sql command. any user definded function or user defined method takes much more time to finish when it is called occasionaly. but when the same procedure is called quite often it finishes a lot faster. why?

View 1 Replies

Run A SQL Stored Procedure ?

Jan 26, 2012

I am currently building an ASPX webpage for internal use. Basically, there are two buttons on this page and I need each one to kick off a different stored procedure on our local SQLServer based on the needed task. these stored rocedures do quite a bit of work and take 3-5 minutes to finish running. In neither case do I need any kind of gridview or other output from these stored procedures, as they are simply crunching/cleaning data that will populate some tables that the user will then use to complete their task. There are also no inputs or parameters needed.

So i'm OK at ASPX and pretty good at SQL, but have no idea on the VB code behind page. This is what I have ben able to put together based on 3 days of googling. i think i am close but can't quite get across the line.

CODE:

I'm not sure if you need to see any of my ASPX or my SQL. both work fine on their own, but i am not able to get these buttons to work.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved