C# - ADO.NET Batch Insert With Over 2000 Parameters?
Mar 19, 2010
I'm using Enterprise library, but the idea is the same. I have a SqlStringCommand and the sql
is constructed using StringBuilder in the forms of
"insert into table (column1, column2, column3) values (@param1-X, @param2-X, @parm3-X)"+" "
where "X" represents a "for loop" about 700 rows
StringBuilder sb = new StringBuilder();
for(int i=0; i<700; i++)
{
sb.Append("insert into table (column1, column2, column3) values (@param1-"+i+", @param2-"+i, +",@parm3-"+i+") " );
}
followed by constructing a command object injecting all the parameters w/ values into it.
Essentially, 700 rows with 3 parameters, I ended up with 2100 parameters for this "one sql" Statement.
It ran fine for about a few days and suddenly I got this error
===============================================================
A severe error occurred on the current command. The results, if any, should be discarded.
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)
[code]...
View 3 Replies
Similar Messages:
Jan 25, 2010
I have a text file (test.txt) which contains n number of data like:
1234778
4567444
8970451
1212455
testhsdd
weresdfy
.
.
.
etc
I need to fetch first 75 data or lines and insert in the sql table. Again next 75 data or lines and insert in the sql table. Again next 75 data or lines and insert in the sql table until it finish all.How i can do it in ASP.NET with C#
View 6 Replies
Jul 13, 2010
Getting the message that ObjectDataSource ... count not find a non-generic method ... that has parameters ... The parameter list is fine until I get to the very end and it list the two data fields that are in my DetailsView. Using the ASP Tutorial #17 (Examining the Events Associated with Inserting, Updating, and Deleting) and the Exploring the Data Modification - specifically the one showing the INSERT of the Product Name and UnitPrice. ASPX page is pretty simple and attempting something similar, two fields to insert a new record - update the other fields later.
Full Error Message follows along with ASPX and the AsignaturasBLL.cs. Interesting thing is that when I swap the two fields in the DetailView, then the last two fields in the error message are swapped. In the error message I bolded these two fields.
[Code]....
View 6 Replies
Jul 21, 2010
moving some tables & stored procedures from SQL Server 2000, to SQL Server 2005.So far so good, but I've come across a problem with this stored procedure:
CREATE PROCEDURE [dbo].[user_insert]
@user_service_unit int,
@user_champion_1 varchar(50),
@user_champion_1_nt varchar(10),
@user_champion_2 varchar(50),
@user_champion_2_nt varchar(10),
@user_champion_3 varchar(50),
@user_champion_3_nt varchar(10),
@user_date_received datetime,
@user_requestor varchar(255),
@user_info_requested text,
@user_expiry_date datetime,
@user_10_days datetime,
@user_5_days datetime,
@user_2_days datetime
[code]...
View 3 Replies
Mar 9, 2010
if i do this to set the fetch parameters:
dsList.SelectParameters["client_id"].DefaultValue = Session["client_id"].ToString();
where dsList is my datasource, it works.
but wen i do the samething for the *%^&* insert, it doesnt:
dsList.InsertParameters["client_id"].DefaultValue ="1234";
it keeps saying its null, i dont understand why it woudl be doing this?
View 2 Replies
Dec 22, 2010
I would like to create a common stored procedure for all insert operations performed in my Database. So i created a stored procedure as below.
[Code]....
But now my problem is how to pass parameters for this stored procedure. I have got the column names of the table passed. But i would like to pass the parameters for each insert operation of each table to identify which value is passed for which parameter.
how to pass parameters for this stored procedure.
(Parameter can be Column name prefixed @ i.e. @Column name)
It is possible to get the column names in another Stored Procedure . But how to prefix @ for each column and pass this as parameter to the Common Insert Stored Procedure?
View 11 Replies
Sep 29, 2010
Are they any special Insert Paramters I shoud/need to use on a formView. I currently have the below datasource but when submitted it only inserts <NULLS> intot he required table.
[Code]....
The fields that aren't being inserted are already pre-populated via the following used FormViews:
[Code]....
View 10 Replies
Feb 1, 2010
I have been in the process of updating my code with security methods, and I've been learning this from [URL] (or "Security Guidelines: ASP.NET 2.0"). In the middle of the page under "When Constructing SQL Queries, Use Type Safe SQL Parameters" it says "Use type safe parameters when constructing SQL queries to avoid possible SQL injection attacks that can occur with unfiltered input". Now, what they suggested was to use code like:
"DataSet userDataset = new DataSet();
SqlDataAdapter myCommand = new SqlDataAdapter(LoginStoredProcedure", connection);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
myCommand.SelectCommand.Parameters.Add("@au_id", SqlDbType.VarChar, 11);........"
But, I was already using code like:
"var dataSource = (SqlDataSource)form1.FindControl("sqlDataSource5") ;
dataSource.UpdateParameters.Add("someVal", val);"
So now, to use type safe parameters, I decided to include it like:
"var dataSource = (SqlDataSource)form1.FindControl("sqlDataSource5") ;
dataSource.UpdateParameters.Add("@someVal", DbType.Int16, val);
dataSource.UpdateParameters["@someVal"].Size = 1;"
So, that would be how I would modify my current code base to use type safe parameters in sql updating/inserting.
Getting to my actual question, as it was said "Use type safe parameters when constructing SQL queries to avoid possible SQL injection attacks that can occur with unfiltered input". First off, this suggests that this should apply to unfiltered input. Also, in their example they only did this for an ID.
So, what I'd like to know, when it comes to "unfiltered input", does this mean as long as the input is unfiltered I must use type safe parameters, or even filtered input shall have this (just to be sure), like, input that has been ran through a regularexpression check? Shall I do this for all values I insert/update into the database, or just IDs and important things?
The way I see it right now is that it would be a good precaution to just do type safe checks on everything (literally) that updates/inserts into the database just to be extra safe. But, I really am unsure if this is really the best idea, because if I did, would this possibly cause overprocessing of information? Can this cause too much strain on server resources? If my fears serve true, what would be a good suggestion of how I could implement this properly without having to worry about what I said?
View 1 Replies
Jan 14, 2011
I am pretty sure this is a basic syntax error, I am new at this and basically figuring things out by trial and error... I am trying to insert data from textboxes into an Access database, where the primary key fields in tableCourse are prefix and course_number. It keeps giving me the "no value given for one or more required parameters" error. Here is my codebehind:
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
'Collect Data
Dim myDept = txtDept.Text
Dim myFirst = txtFirstName.Text
Dim myLast = txtLastName.Text
Dim myPrefix = txtCoursePrefix.Text
Dim myNum = txtCourseNum.Text
[Code]...
And it inserts the data, I checked the database and it's all there, but it still gives me an error:
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
View 4 Replies
May 26, 2010
For my first project in vwd2008 with asp/vb i've created a work order system and everything's going well.. I use a gridview to show all work orders, and then i've been using a hyperlinkfield to link to a seperate page so that they can view and print the work order.
I've now been tasked with making it possible to print multiple work orders at once. How can i print multiple html pages at once without the user having to choose a printer each time?
I figure i can setup a checkbox for them to select the work orders.. and then create html links to each of the work orders..And then just use a button to start printing... ..but how would i print each of them?
[URL]
View 2 Replies
Sep 29, 2010
Apologies if my question is too broad but I eed pointers on how to tackle the following problem. Currently, I run a batch file that launches a series of automation tests on QTP (a test automation tool). The batch file contains a vbs script path and it takes three parameters. Each time smeone needs to run the automation, I have to do this manually.What I'd like to be able to do is to allow other members of the team to access this functionality via an intranet web page. They would be able to login, choose the tests to run and then run them. My only other requirement is that the solution be based on .net and C# if possible. My current server is 2003 SP2.What is the best way to achiveve what I want? What is the recommended version of IIS and .NET framework to use? How do I configure IIS to be able to run the vbs script? I'm looking for a step-by-step approach if possible. I don't care if I have to convert the batch file into an executable or run the script directly, just as long as it is launched.
View 3 Replies
Jan 5, 2010
We have a module in a system called Batch Upload. The function of this module is a user will upload a file and we have to upload the content of the file in the database. I already used excel file but it just compatible in 32bit. I think of a CSV file format then we will validate the file and upload the valid data in the database. Does anyone know how to do Batch Upload in CSV format?
View 1 Replies
Apr 12, 2010
I want to schedule a batch process in my APPLICATION SERVER every night by calling a stored in my database.
View 4 Replies
Dec 3, 2010
I have a problem which is a recent development. We used to be able to run a batch file from IIS, but now we can't. I have tried several different approaches to this issue, none of them have worked. I tried to run the batch file under cmd using CreateProcess, CreateProcessWithLoginW, CreateProcessAs User, none of which worked. I now know that CreateProcesswithLogonW won't work on Windows 2003 Server. This is a C++ webservice by the way, running on Windows 2003 server using IIS 5.1. I have also tried running the batch file from a vbs script and calling the script in C++ using system("Scriptname") and that does not work either. I have run out of options, or at least the options that I know about.
I learned that "EXEs in System32, which like CMD.EXE have "special" ACLs that prevent them from being launched remotely from IIS. CMD.EXE has further security checks inside of it to prevent being used to launch batch scripts launched remotely from IIS." So I have abondoned even attempting to run CreateProcess of anykind where I invoke "cmd.exe" to run a batch file. Which was why I tried the vbscript. I know this is a security issue. It has to do with either the NETWORK SERVICE account or the ASPNET account not having permission to do this. I have QA breathing down my neck at this point and I really need to figure out what to do. If it is a security setting that can be set without compromising security on the server then great (although I bet that isn't the case).
View 1 Replies
Mar 14, 2011
I've tried searching for the best method of doing batch uploads to YouTube but I've only found methods for uploading a single video to YouTube (which is fine, but not my situation).
I'd like to know the best method of uploading multiple videos to YouTube. I noticed here:
[URL]
That it needs to be spread out so you don't reach the quota. However, I noticed that Batch Processing is available here:
[URL]
Is it possible to create a batch upload to YouTube using the request.Batch call? Or is the only method to loop through the videos to be uploaded and upload them one at a time (given a 3-5 minute delay between each one)?
View 1 Replies
Jan 17, 2011
I need to know, how can one create a batch file(.bat) and run the same at a specified time (say everyday at 12am midnight) in asp.net(C#).
View 4 Replies
Aug 17, 2010
I need to add potentially a large number of items to a dataset, this currently works but is quite slow. There are some minor changes I can make to make this fast however the main culprates are the insert statements which are quite complex, With the deletes I changed the structure to be DELETE FROM TABLE WHERE ID IN () Instead of a per ID statement which made quite a difference executing for every 25 rows.The SPROC is linq enabled DbContext.MYSPROC(params) is there a way I could add the Sproc in the context to a batch group that I then execute when the currrent count of insertable items = 25? for each item in insertitems 'Don't want it to execute here
Batch.AddSproc(DbContext.MYSPROC(params))
If Count = 25 THEN Batch.RunSProcs
next
View 2 Replies
Mar 17, 2010
what exactly the batch debug option in web.config (attribute) does? I can tell it debugs in batches ( >1) but I cannot find anymore background info on this setting.
View 1 Replies
Sep 4, 2010
I am creating an intranet application which runs a batch file and create an xml file as result. Which i am using for further processing. My problem is when i am running my application from local machine batch file is running fine and creating xml,but when i am running it through iis nohting is happening,
it meance process.start coudn't start command Prompt.
I am using following code. I have given all permission to iis.
Dim ProcessInfo As Diagnostics.ProcessStartInfo
ProcessInfo = New Diagnostics.ProcessStartInfo("cmd.exe", "/C " + Server.MapPath("~myScript.bat"))
Dim Process As New Diagnostics.Process
ProcessInfo.CreateNoWindow = False
ProcessInfo.UseShellExecute = False
[code]...
View 3 Replies
Mar 10, 2011
We have a set of about 30-50 users who periodically need an ASP.net (version 4) application directory created for them.
As these numbers grow, manually creating an application directory for each user becomes cumbersome on IIS 7.
Is there a way to create these application folders using a batched/scripted/automated mechanism of some kind?
Ideally we'd like to provide input parameters of a file that contains a batch of application-names, and have the script automatically create the application directories in IIS.
View 3 Replies
Jan 13, 2011
I'm using the System.Diagnostics.Process class to run a batch file. I need to be able to take an output from the batch file and then display it on the web-page, basically to know if it succeeded or not, since the batch runs an .exe that doesn't always succeed.
the values returned by the .exe and have the batch run a script depending on the value returned. The script could be a VBscript that sends info to the webpage, but even then I'm not sure how to accomplish this.
View 4 Replies
Feb 4, 2010
I have a batch file on another server on a different domain or network that I need to run from an ASP page. I found a simple enough script that opens a CMD prompt, goes to the location of the batch and runs it. If everything is on the same machine, it runs fine.
The issue I've run into now is that the batch file is on a file server and the ASP page is on a IIS server. The File server is on a internal network (separate domain) and the IIS server is on an external network (or different domain), both servers are hosted here.
When I try it and look at the event logs I can see a failure audit and its trying to login with the machine name.
View 1 Replies
Sep 10, 2010
In a regular webform, I can enable a batch of textboxes Visibility switch on with the following command...
[Code]....
View 1 Replies
Sep 29, 2010
I have to open a batch file automatically in sql. So i have used the below command.EXECUTE master.dbo.xp_cmdshell 'D:Databasesatch123.bat'Its worked for few times. After that its not working.One time i have stopped before the process is complete.May be this is the issue.Now its returns null value.
View 4 Replies
Jan 8, 2010
i have made one web site which is generating screensaver(MSI) dynamically.So to generate the MSI file i have to build a WIX project.So i executed using batch file which will use MSBuild.exe and cmd prompt. so its gave me an error "Access is Denied". i have also tried by making a windiws service but still the same error occurs.
View 1 Replies