MASS INSERT FROM VB.NET PROGRAM TO DB

Oct 4, 2007

I have the following problem. I need to insert 100.000 records (50Kb each) in one operation from a VB program into a SQL Server 2005 database. All of these records will be ready for inserting at the same time.
How to make this insert as one big transaction instead of 100.000 small ones?

View 2 Replies


ADVERTISEMENT

Mass Insert / Update External Data Into Internal SQL Database

Nov 15, 2006

Hola!I'm currently building a site that uses an external database to store all the product details, and an internal database that will act as a cache so that we don't have to keep hitting the external database to retrieve the products every time a customer requests a list.What I need to do is retrieve all these products from External and insert them into Internal if they don't exist - if they do already exist then I have to update Internal with new prices, number in stock etc.I was wondering if there was a way to insert / update these products en-mass without looping through and building a new insert / update query for every product - there could be thousands at a time!Does anyone have any ideas or could you point me in the right direction?I'm thinking that because I need to check if the products exist in a different data store than the original source, I don't have a choice but to loop through them all.Cheers,G. 

View 2 Replies View Related

I Hava Program Mssql Insert

Dec 23, 2006

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Page.IsPostBack Then
binddata()
End If
End Sub
Sub binddata()
baglanti = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|datagoldbar.mdf;Integrated Security=True;User Instance=True")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cmd As New SqlCommand("INSERT INTO db " & _
"(ip,sehir,mesaj,email) VALUES (@ip, " & _
"@sehir,@mesaj,@email)", baglanti)
cmd.Parameters.Add("@ip", SqlDbType.NVarChar, 50).Value = isim.Text
cmd.Parameters.Add("@sehir", SqlDbType.NChar, 50).Value = sehir.Text
cmd.Parameters.Add("@mesaj", SqlDbType.NText).Value = mesaj.Text
cmd.Parameters.Add("@email", SqlDbType.NVarChar, 150).Value = email.Text
baglanti.Open()
cmd.ExecuteNonQuery()
binddata()
 
 
 
End Sub
Server Error in
 Object reference not set to an instance of an object.
where is mistake there?



 

View 4 Replies View Related

DBCC Interrupting Long Running INSERT Program

Mar 7, 2001

My program is copying several hundred thousand records from an Access DB to a sql server 7 db. It has to do some conversions and lookups along the way. At seemingly random times, a DBCC job gets started up by the system that locks up my program.

Any thoughts as to why it happens? What I can do to detect/prevent it so that my program doesn't lock up?

View 6 Replies View Related

In Merge Replication How To Insert A Data??? Program Is Getting Stuck

Apr 19, 2008

Hi all,


there are 2 datagrids i have taken,

1st for displaying data before inserting the value into table
2nd for displaying data after inserting the value into table
just see the screeenshot which i have taken


actually the problem is, we are not getting any type of errors even though I have try/catch blocks.
I have colored that particular statement in RED color, where it is getting stuck, while executing, if we sit 40-45 minutes then also the execution pointer is not going on next step.




please look into this, and if u have any idea/person by which/whom we can solve this then please tell us.......




-chaukse rahul








using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Data.SqlServerCe;
using System.Data.Common;

namespace ProjectSQLMobile2
{
public partial class Form1 : Form
{
private DataSet dsMemberList;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Sync();
}

private void Sync()
{
SqlCeReplication repl = new SqlCeReplication();


repl.InternetUrl = @"http://169.254.25.129/WebSQLMobile/sqlcesa30.dll";
repl.Publisher = @"RAHU";
repl.PublisherDatabase = @"SQLMobile";
repl.PublisherSecurityMode = SecurityType.DBAuthentication;
repl.PublisherLogin = @"sa";
repl.PublisherPassword = @"sa12345";
repl.Publication = @"PubSQLMobile";
repl.Subscriber = @"SubSQLMobile";
repl.SubscriberConnectionString = @"Data Source=TestLast.sdf;Max Database Size=128;Default Lock Escalation =100;";

try
{
if (!System.IO.File.Exists(@"TestLast.sdf"))
{
repl.AddSubscription(AddOption.CreateDatabase);
}
repl.Synchronize();
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
finally
{
repl.Dispose();
}

/*
*
* To Display Data Into DataGrid1 Before Insert
*
*/

SqlCeConnection cn = new SqlCeConnection(@"Data Source=TestLast.sdf");


SqlCeDataAdapter daMemberList = new SqlCeDataAdapter("SELECT MemberID, MemberName FROM MembershipData", cn);

if (dsMemberList == null)
{
dsMemberList = new DataSet();
}
try
{
dsMemberList.Clear();
daMemberList.Fill(dsMemberList, "MembershipData");
dataGrid1.DataSource = dsMemberList.Tables["MembershipData"];
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
}

private void Merge()
{
SqlCeReplication repl = new SqlCeReplication();

repl.InternetUrl = @"http://169.254.25.129/WebSQLMobile/sqlcesa30.dll";
repl.Publisher = @"RAHU";
repl.PublisherDatabase = @"SQLMobile";
repl.PublisherSecurityMode = SecurityType.DBAuthentication;
repl.PublisherLogin = @"sa";
repl.PublisherPassword = @"sa12345";
repl.Publication = @"PubSQLMobile";
repl.Subscriber = @"SubSQLMobile";
repl.SubscriberConnectionString = @"Data Source=TestLast.sdf;Max Database Size=128;Default Lock Escalation =100;";


try
{
if (!System.IO.File.Exists(@"TestLast.sdf"))
{
repl.AddSubscription(AddOption.CreateDatabase);
}
repl.Synchronize();
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
finally
{
repl.Dispose();
}


/*
*
* To Display Data Into DataGrid2 After Insert
*
*/

SqlCeConnection cn = new SqlCeConnection(@"Data Source=TestLast.sdf");
SqlCeDataAdapter daMemberList = new SqlCeDataAdapter("SELECT MemberID, MemberName FROM MembershipData", cn);
if (dsMemberList == null)
{
dsMemberList = new DataSet();
}
try
{
dsMemberList.Clear();
daMemberList.Fill(dsMemberList, "MembershipData");
dataGrid2.DataSource = dsMemberList.Tables["MembershipData"];
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
}

private void DisplaySQLCEErrors(SqlCeException ex)
{
for (int i = 0; i < ex.Errors.Count; i++)
{
MessageBox.Show("Index #" + i.ToString() + ""
+ ex.Errors.Source + ""
+ "Error: " + ex.Errors.Message,
"Error No. " + ex.Errors.NativeError.ToString());
}
}

private void buttonInsertData_Click(object sender, EventArgs e)
{
//add directly into ce database sample:
SqlCeConnection cn = new SqlCeConnection(@"Data Source=""TestLast.sdf""");
string SQL = "INSERT INTO MembershipData(MemberName) VALUES('" + textBox1.Text + "')";
cn.Open();
SqlCeCommand cmd = new SqlCeCommand(SQL, cn);
cmd.CommandType = CommandType.Text;

try
{
/*
* This statement is taking too much time to be executed * what should we do??????? */ cmd.ExecuteNonQuery(); }
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
finally
{
cn.Close();
}
Merge();
}
}
}




please help,

ur help will be appriciates




NOTE:- I am getting output in 1st datagrid, but in 2nd dtagrid there is no output

View 1 Replies View Related

How Can I Insert Date In SQL Server 2000 Database (table )from ASP.NET 1.1. Program??

Feb 1, 2006

hi ALL !!!
How can I insert Date in SQL Server 2000 database(table ) from ASP.NET 1.1. Program??
pls send me code if u can
pls help me ..

View 2 Replies View Related

Do Sqlexception Breaks The Functionality Of The Program? (program Flow)

May 23, 2007

why we use sql exceptions ...

what the program will do if we caught that exception .. i need some suggestions ... i got this exception(String or binary data would be truncated.
The statement has been terminated.).. will it affect the functionality of the program...

hiow can i avoid this exception..

View 1 Replies View Related

It Takes A Long Time To Insert The First Record Each Time When The Program Start

Dec 15, 2006

I am using VS2005 (VB) to develop a PPC WM5.0 Program. And I am using SQLCE 3.0. My PPC Hardware is in 400MHz.

The question is when the program try to insert the first record into sdf database after each time the program started. It takes a long time. Does anyone know why and how can I fix it?

I will load the whole database into a dataset when the program start and do all the "Insert", "Update", "Delete" in this dataset and fill it into database after each action.

        cn.Open()
        sda = New SqlCeDataAdapter(SQL, cn) 'SQL = Select * From Table
        scb = New SqlCeCommandBuilder(sda) 
        sda.Update(dataset)
        cn.Close()

I check the sda.update(), it takes about 0.08s for filling one record into database normally. But:

1. Start the PPC Program

2. Load DB into dataset

3. Create a ONE new record in dataset

4. Fill back to DB

When I take this four steps everytime, the filling time is almost 1s or even more!

Actually, 0.08s is just a normal case. Sometimes, it still takes over 1s to filling back a dataset which only inserted one record when the program is running. (Even all inserted records are exactly the same in data jsut different in the integer key)

 However, when I give up the dataset and using the following code:

            cn.Open()
            Dim cmd As New SqlCeCommand(SQL, cn) ' I have build the insert SQL before (Insert Into Table values(XXXXXXXXXXXXXXX All field)

           cmd.CommandType = CommandType.Text
            cmd.ExecuteNonQuery()
            cn.Close()
            StartTime = Environment.TickCount

 I found that it is still the same that the first inserted record takes more time, but just about 0.2s. And the normal insert time is around 0.02s. It is 4 times faster!!!

View 1 Replies View Related

Can I Return A Value In A Variable From A SSIS Program Back To C# After The SSIS Program Is Run From C#?

May 21, 2007

Can I return a value in a variable from a SSIS program back to C# after the SSIS program is run from C#?

View 1 Replies View Related

Mass Update In SQL

Apr 25, 2008

I have a Hits table that tracks the hits on the id of a Link table:
Hits:
int linkId (foreign Key to Link)
datetime dateCreated
varchar(50) ip
We recently had to merge Links from different systems that are implemented similarly.  As a result, all the linkIds are now wrong in the Hits table because the ids all changed.  I managed to track down all the old ids and their associated new ids and have it in a table that I call joined_links
joined_linksint oldId
int newId
 
So, how do I do a mass update of these linkIds in the Hits table in SQL?  I know I could do it in .NET, but I'd rather not write an app to do that runs thousands of update statements.  There's gotta be a way to do it something like this:
 
UPDATE Hits h SET h.linkId = (SELECT newId FROM joined_links WHERE oldId=h.linkId)
but obviously I don't have visibility of that linkId in the subselect...  A Loop maybe?

View 6 Replies View Related

Mass DTS Modification

Aug 13, 2004

I have a series of DTS packages.
Each package has 20 queries.
Each query has a server name.
Is there a way to change the servername without editing each query in each DTS package.
I'd like to copy the template DTS package, then perform the modification.

Thanks

View 2 Replies View Related

Mass Update

May 8, 2008

This is a run of the mill application that moves orders from one table to another. There are 2 tables, Ordersummary & HstOrders.
Ordersummary has the following columns...
Identifier
FollowupId
OrderNumber
OrderReference
OrderReferenceOrigin
......
......
HstOrders has the following columns...
Identifier
OrderNumber
OrderReference
OrderType
......
......
The above two tables are bound by Identifier. After each month end, Orders are moved from Ordersummary to HstOrders.

Now my task is to update all rows in OrderSummary with the order details as seen in HSTOrders for ordertype = 'CREDIT'. OrderReferenceOrigin(in Ordersummary) should be updated with the value of Orderreference(from hstorders).

I have to update each row at a time & I need to write a cursor for mass updates where ordersummary.identifier = hstorders.identifier.

Can someone please help with in writing this update statement as I never wrote a cursor.

View 1 Replies View Related

Mass Mailing Through SQL Server

Oct 1, 2001

Hi friends,
Any idea about mass mailing system using SQL Server .Pls get back to me.
thanx and regards
Chinmay

View 2 Replies View Related

Is It Possible To Mass Update Stats?

Apr 17, 2006

SQL Server 2000 on Win2k

I'm fairly new to SQL Server and I'm just wondering if it's possible to Update Statistice for all indexes somehow? I'm looking at the Update Statistics command and it doesn't seem to be possible.

The situation we have is a reporting DB that basically has all it's tables truncated and remade every night by some DTS jobs that import from another datasource and change the data and build some denormalzed tables etc.
Some of the large Insert operations go from taking 8 mins to taking several hours sometimes and updating the stats seems to fix the problem for a while. So I'd like to make sure the optimizer has all the latest stats for all tables.

Any other advice would be appreciated.

Cheers.

View 2 Replies View Related

Mass SQL Inserts - Performance :-(

Aug 8, 2006

Hi,

I have an user table with a single integer column. No indexes, no identities, nothing. I have to insert 600,000 rows via a client app. In tests, using BCP/Bulk Insert/DTS all runs OK (sub 3 seconds). However the app takes 5000 rows a second [considerably slower]. I can mimic this slow perfomance, within DTS, by removing the 'Fast Load' & 'Batch' options.

Question= why would the SQL insert run slower on one server and as fast as BCP/Bulk Insert/DTS on another? What can I check on the 'slow' running server? May there be a file version anomally ??

Version = SQL-2000 SP4

Any help much appreciated !!!

View 2 Replies View Related

Mass Updates In SQL Server

Oct 11, 2007

Does anyone know what the best way to do mass updates in SQL server is? I am currently using the methodology suggested in this article

http://www.tek-tips.com/faqs.cfm?fid=3141

But the article is assuming that once I update a field it is going to have a value that is NOT NULL. So I can loop through and update the rows that have a NOT NULL value. But my updated rows do contain NULL values, in this case what is the best way to go about this???

***************************************
Here is my code. I want to avoid using Upd_flag becos
after the following code runs I need to reset that flag
before I run my next query
***************************************

--Set rowcount to 50000 to limit number of inserts per batch
Set rowcount 50000

--Declare variable for row count
Declare @rc int
Set @rc=50000

While @rc=50000
Begin

Begin Transaction

--Use tablockx and holdlock to obtain and hold
--an immediate exclusive table lock. This usually
--speeds the insert because only one lock is needed.


update t_PGBA_DTL With (tablockx, holdlock)
SET t_PGBA_DTL.procedur = A.[Proc code],
t_PGBA_DTL.Upd_flag = 1
FROM t_PGBA_DTL
INNER JOIN CPT_HCPCS_I9_PROC_CODES A
ON t_PGBA_DTL.PROC_CD
= A.[Proc code]
WHERE t_PGBA_DTL.Upd_flag = 0


--Get number of rows updated
--Process will continue until less than 50000
Select @rc=@@rowcount

--Commit the transaction
Commit
End

View 4 Replies View Related

Mass Subscription Email Changes

Nov 15, 2007



The company i work for changed names and all email addresses within the company have changed. While it was OK for a while they are no longer going to be forwarding email to the old addresses to the new ones. There are Tons of subscriptions and tons of email addresses that need to be changed to the new names.

If i could find the table with the TO: part of the subscription held in it i could just run an update on that field and it would be solved...however, i cannot find that field...


So,
Without going into every subscription in report manager, how can i change the email addresses? Any Suggestions?

Thanks in advance

View 1 Replies View Related

How To Best Deploy Mass Packages ???

May 16, 2008

Hi There

Most of the time my solutions consist of 1 or 2 packages and config files work well.

Now i have a solution with about 50 packages i have to move to QA.

However a config file has the package ID, so even thoug they use the same data source connection. I would have to create and change 50 config files.

Data sources are kept in the package xml , so if i copy all the packages to QA , and then change the Global Data Source connection, i still have to open each package maually and save it again.

Surely there must be an easy way to move all 50 packages and have the connection now point to QA. But config files and global data sources dont do the trick, what am i missing here ?

Thanx

View 5 Replies View Related

Mass Import To Sql Server Through Asp.net Vb Style

Feb 25, 2004

I am making a prog that needs to import many records from a spreadsheet on a local computer through asp.net into sql server
is there a simple command to do this or is there information on how to do this
please give all the information that you can thank you

View 9 Replies View Related

Transaction Log Backups (Mass Storage)

May 30, 2002

I want to backing up my hourly transaction log backups direct to a mass storage unit as opposed to the local server. However when trying to set this up it only gives me option of backing up to local drives, even though I have a drive mappping to the mass storage unit.. I'm there is a simple around this.Would appreciate any advice..many Thanks..

View 2 Replies View Related

Software For Performing Mass Design Changes

Jun 28, 2001

Hi,

I was wondering if anyone knows of any way, including third party tools, to replicate a design change on a table across many different databases. I have written an ASP script that allows me to copy multiple tables to multiple databases in one go but I need something that will allow me to replicate the design of a table by comparing source and destination tables. So far I have scripted most of it but I have no idea on which system table to get the identity information and it seems there must be an easier way!

Any help would be appreciated,

Seoras

View 1 Replies View Related

Why Triggers Don't Fire On Mass Update

Mar 4, 2005

If I have a trigger on a field in a table, and I update one record trigger fire properly. If I do a update to that same field on all records in the table the trigger does not fire. I the error in the trigger, or do I need to change my update statement?

View 2 Replies View Related

Mass Import Into Existing Table

Sep 17, 2013

I have an existing SQL table that I want to import 300,000 rows into. I have copied the table headers into Excel and added all the rows but constantly getting multiple errors no matter what way I try to import it.

So far tried Import Method from SQL Management Studio, BULK INSERT and SQL Script. What is the easiest way?

If I try this

select *
into Coupon FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:coupon.xls;HDR=YES',
'SELECT * FROM [coupon$]')

I get

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.

View 9 Replies View Related

Tempdb Filling Up - Mass Deletes

Dec 13, 2007

Hi,

I've been having problems with my tempdb filling up, and causing all databases on the server to stop functioning properly. I've been removing alot of data lately (millions of rows), and I think this is the reason why my tempdb log is going thru an unusual load.

Whats the best way to make sure the tempdb doesnt fill up causing me major problems? I had temporarily turned off backups while I was having a new HD put in. Am I right in thinking that when a DB is backed up, the tempdb log is reduced in size? Should maintaining a daily backup solution help keep things under control ?

Thanks very much for any tips!

mike123

View 4 Replies View Related

Mass Update On Table With Trigger

Jun 29, 2007

Hi,I need to update a field in about 20 records on a table. The table hasan update trigger (which updates the [lastedited] field whenever arecord is updated). As a result I'm getting an error: "Subqueryreturned more than 1 value.", and the update fails.Is there a way in the stored procedure to handle this issue?thanks for your help.Paul

View 2 Replies View Related

Sql Slowed To A Crawl After Deleting Mass Rows

Apr 25, 2007

Hi,

I've deleted about 3-4 million rows from one of my tables as the data was old and no longer needed. The problem is that now queries are runnning extra slow. I am in the process of running taras isp_ALTER_INDEX however its taking quite a long time and seems to be slowing things down even further while its running as expected. (It's been running 4 hours already, I have stopped it and will rerun it a slower traffic period for the db server)

Just wondering if I have the right approach here or if anyone else has any suggestions.

Thanks for your help!

View 14 Replies View Related

Mass Alter Table Fields - Script Help

Jun 27, 2007

Hello,I need to alter fields in all my tables of a given database, and Iwould to do this via a t-sql script.Example, I want to change all fields called SESSION_ID to char(6). Thefield is usually varchar(10), but the data is always 6 characters inlength. I have serveral fields that are fixed length that I want tomove from varchar to char.I believe I can find all the tables where the field exists usingselect * from INFORMATION_SCHEMA.columns where column_name ='SESSION_Id'but I dont know how to take this into an ALTER TABLE , ALTER COLUMNthat can be automatedTIARob

View 2 Replies View Related

Mass Table Structure Change For Column Order

Feb 26, 2008



Say you have an existing populated SQL 2005 database, with 700+ tables, and you want to just change the order of the columns inside every table. Short of manually building conversion scripts, anyone know an automated way to do this? I was thinking thru ways to do them all in one shot, and have tools like Erwin and DbGhost that could be used also. Basically moving some standard audit columns from the end of the tables to just after the PK columns.

Thanks, Bruce

View 8 Replies View Related

Is There A Way To Do Mass Formatting Of Cells In A Table Instead Of Cell By Cell?

Oct 5, 2007



Hi,
I'm working with MRS and I've got a table with a lot of entries. For each value in the table I'm trying to get the text colour to be set to 'red' when the value of the cell is less than 0. Otherwise remain black.

I can do this by setting the colour property cell by cell. But I have a lot of cells in the table. Is there a way to set the statement to apply to ALL cells in the table?

Basically I'm asking if there is a way to set the property in bulk instead of going through tediously cell by cell.

Any help would be much appreciated. Thanks!

View 4 Replies View Related

Help In Program

Aug 29, 2001

i have a program which should give the out like this
XAPIALTMKT20010829105525.TXT

but its giving the output = 'X'
which is just the first initial...how
can i get this...

if i don't write the @filename=....
only then its giving the output..but i want to store it in the
varable..how can i do that
================================
declare
@v datetime ,
@filename varchar

select @v=getdate()
select @filename='XAPIALTMKT'
+CONVERT(varchar, @v, 112)
+SUBSTRING(CONVERT(varchar, @v, 108), 1, 2)
+SUBSTRING(CONVERT(varchar, @v, 108), 4, 2)
+SUBSTRING(CONVERT(varchar, @v, 108), 7, 2)
+'.TXT'

print @filename
================================================

thanks,
Harish

View 2 Replies View Related

Get With The Program

Jul 23, 2005

It is very interesting to me that most people in this group can't do simpleSQL. Are you viewing MySQL as a simple file system?As long as you do that,you willnot understand SQL in any dialect. So from now on:When you have a question about SQL. post the table structures. Uh, "WithCreate".Post some sample data in the form of INSERTS.Regards,Rich--The journey is the reward.

View 2 Replies View Related

SQL Program Question

May 22, 2006

Hello, i installed :

SQL Server 2005 Express Edition with Advanced Services
Install Microsoft SQL Server 2005 Express Edition with Advanced Services

but I do not see any program in my program menu to open it. Is this a stand alone program I can open? Thanks

View 2 Replies View Related

Mailsend Program

Oct 10, 2007

Hi All,

I am trying to send an email from a cmd prompt from SQL Server 2005 server using mailsend program. I am getting the message "Could not send mail". I am really stumped, don't know how to fix it. Any suggesstions?

Thanks.

View 3 Replies View Related







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