473,624 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

easy way of creating update commands?

cj
I have lots of tables to copy from one server to another. The new
tables have been created to match the old ones. I practiced with one
table. I created the select command (select * from tableA) and Visual
Basic .NET created an update command--very long as there are a lot of
fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables
with out having to set up a new dataadapter for each table? Then I
could just assign it a new select and update command and use the same
dataadapter.
Dec 15 '05 #1
10 1631
Hi,

Thanks for your post.

Yes, *DataAdapter class is just a set of data commands and a database
connection that are used to fill the DataSet and update a SQL Server
database. It contains *Command objects to do the actual update/add/delete
etc.. operations.

We can reuse one *DataAdapter class to do different database operations.
After doing one SQL command, we can change it to execute another operation
like this:
*DataAdapter.Up dateCommand.Com mandText ="command text"
*DataAdapter.Se lectCommand.Com mandText ="command text"
*DataAdapter.De leteCommand.Com mandText ="command text"
*DataAdapter.In sertCommand .CommandText ="command text"

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 16 '05 #2
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply the
commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less than
100 fields.

I hope this helps,

Cor
I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables with
out having to set up a new dataadapter for each table? Then I could just
assign it a new select and update command and use the same dataadapter.

Dec 16 '05 #3
cj
Hi Jeffrey, Perhaps I could have done a better job of explaining my
wishes. I have identical tables in different databases on different
servers. I wish to move all the rows from TableA on Server 1 to TableA
on Server 2. Then I want to move all the rows from tables B-Z

I got the code written for TableA Adding hand coding connection to the
source and making a sqldataadapter with the wizards for the destination.
I choose to use the wizards for the destination because unlike a
select where the statement is short and sweet (select * from TableA) the
insert statement is very long as it list all the column names twice and
there are lots of columns.

My intention was to run this same code on tables B-Z as well but I
failed to take into consideration the insert command that was created
for tableA wouldn't work on tables B-Z. I want VB to make it easy on me
and figure out it's own insert statement for tables B-Z w/o me having to
add a seperate sqldataadapter for those tables.

Is there a way to do this?

Jeffrey Tan[MSFT] wrote:
Hi,

Thanks for your post.

Yes, *DataAdapter class is just a set of data commands and a database
connection that are used to fill the DataSet and update a SQL Server
database. It contains *Command objects to do the actual update/add/delete
etc.. operations.

We can reuse one *DataAdapter class to do different database operations.
After doing one SQL command, we can change it to execute another operation
like this:
*DataAdapter.Up dateCommand.Com mandText ="command text"
*DataAdapter.Se lectCommand.Com mandText ="command text"
*DataAdapter.De leteCommand.Com mandText ="command text"
*DataAdapter.In sertCommand .CommandText ="command text"

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 16 '05 #4
cj
See my answer to Jeffrey, Perhaps command builder is something that
would help. I don't know anything about it. I'll look at your link.
While there are a lot of fields it isn't over 100.

Cor Ligthert [MVP] wrote:
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply the
commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less than
100 fields.

I hope this helps,

Cor

I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables with
out having to set up a new dataadapter for each table? Then I could just
assign it a new select and update command and use the same dataadapter.


Dec 16 '05 #5
You might be able to write a generalized function/sub that:

Fills a dataset from your old database
Creates a table in your new database using the schema from that dataset
Fill a new dataset from the new database (will have 0 rows)
Copy the rows from the old dataset into the new dataset
Update the new dataset

Probably is a better way to do it but the above should work.

Dennis in Houston
"cj" wrote:
See my answer to Jeffrey, Perhaps command builder is something that
would help. I don't know anything about it. I'll look at your link.
While there are a lot of fields it isn't over 100.

Cor Ligthert [MVP] wrote:
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply the
commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less than
100 fields.

I hope this helps,

Cor

I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables with
out having to set up a new dataadapter for each table? Then I could just
assign it a new select and update command and use the same dataadapter.


Dec 16 '05 #6
cj
It'll take me a little playing with because I haven't worked with
creating a table using the schema from a database but that sounds like a
good idea. I'd rather work on figuring out how to do this rather than
put my time into typing in all those insert statements.
Dennis wrote:
You might be able to write a generalized function/sub that:

Fills a dataset from your old database
Creates a table in your new database using the schema from that dataset
Fill a new dataset from the new database (will have 0 rows)
Copy the rows from the old dataset into the new dataset
Update the new dataset

Probably is a better way to do it but the above should work.

Dennis in Houston
"cj" wrote:

See my answer to Jeffrey, Perhaps command builder is something that
would help. I don't know anything about it. I'll look at your link.
While there are a lot of fields it isn't over 100.

Cor Ligthert [MVP] wrote:
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply the
commandbuild er.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less than
100 fields.

I hope this helps,

Cor

I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables with
out having to set up a new dataadapter for each table? Then I could just
assign it a new select and update command and use the same dataadapter.

Dec 16 '05 #7
CJ,

If this is a one time opration, than it is probably much better to use the
tools given for that by the database.

If you really want to do it, than don't forget this

http://msdn2.microsoft.com/en-us/lib...uringfill.aspx

I hope this helps,

Cor
"cj" <cj@nospam.nosp am> schreef in bericht
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
See my answer to Jeffrey, Perhaps command builder is something that would
help. I don't know anything about it. I'll look at your link. While
there are a lot of fields it isn't over 100.

Cor Ligthert [MVP] wrote:
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply
the commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less
than 100 fields.

I hope this helps,

Cor

I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables
with out having to set up a new dataadapter for each table? Then I could
just assign it a new select and update command and use the same
dataadapte r.



Dec 16 '05 #8
cj
It's kinda a one time thing. Problem is I've been asked to do this to
combine a database that is kept by each of our companies sites
individually on their own servers into one SQL server. Unfortunately I
don't really have access to the "from" databases or the servers they are
on beyond being able to query them--office politics.

Oh, I'm glad you asked that because that just made me think of another
problem. I can't really let the program create the tables on the new
server. While that'd be great as I get the tables from the first site
when I go to do the second site I'll be adding those tables's data to
tables on the SQL sever that already contain data from previous sites.

Well, I still haven't had time to look at the command builder. I'll
look at it and if I can't figure it out or it doesn't seem to be helpful
I'll have to bit the bullet an start typing those long insert commands.

Cor Ligthert [MVP] wrote:
CJ,

If this is a one time opration, than it is probably much better to use the
tools given for that by the database.

If you really want to do it, than don't forget this

http://msdn2.microsoft.com/en-us/lib...uringfill.aspx

I hope this helps,

Cor
"cj" <cj@nospam.nosp am> schreef in bericht
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
See my answer to Jeffrey, Perhaps command builder is something that would
help. I don't know anything about it. I'll look at your link. While
there are a lot of fields it isn't over 100.

Cor Ligthert [MVP] wrote:
CJ,

In addition to Jeffrey.

Although from the information that you have given the idea that your
solution will not work, does your question in my opinion directly apply
the commandbuilder.

http://msdn.microsoft.com/library/de...classtopic.asp

Be aware that as every wizard it will only work with tables with less
than 100 fields.

I hope this helps,

Cor

I have lots of tables to copy from one server to another. The new tables
have been created to match the old ones. I practiced with one table. I
created the select command (select * from tableA) and Visual Basic .NET
created an update command--very long as there are a lot of fields.

Now there are more large tables to copy. Is there an easy way to have
Visual Basic create these update commands itself for the other tables
with out having to set up a new dataadapter for each table? Then I could
just assign it a new select and update command and use the same
dataadapter .

Dec 16 '05 #9
CJ,
Well, I still haven't had time to look at the command builder. I'll look
at it and if I can't figure it out or it doesn't seem to be helpful I'll
have to bit the bullet an start typing those long insert commands.

Your explanation can be an real one, however more difficult than the insert
is create the tables on the new database (which needs the exact same names
and valuetypes).

For the insert you can probably in this case use the commandbuilder. However
than as Dennis in fact wrote already you have to be sure that the receiving
databasetable has no conflictiong rows.

Than you have in my opinion got from us all the ingredients you need.

If you than have questions after a while, ask than again. In my opinion can
you use in this the commandbuilder.

Cor
Dec 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5961
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1; this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ApplicantName", dataset.Tables.Columns.DataType, 50,
4
3801
by: Oscar Thornell | last post by:
Hi, I have a relativley large/complex typed dataset that contains 7-8 tables and some supporting relational tables (lookups) for many-to-many relations. A good exampel would be a dataset that contained the whole Northwind database with all tables and relations. In my business logic I will retrive a populated instance of the dataset and perform some operations (adding/deleting/updating of rows in various tables...).
4
2144
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft SQL database "pubs". I've followed the instructions in the comments and also changed everything pertaining to SQL over to OLEDB. (i.e. Changed SqlDbType. to OleDbType.) I also changed the datafield names and variable names accordingly. The page...
3
1792
by: RJN | last post by:
Hi I'm using the Dataadapter and Dataset to do an insert/update/delete into tables. The dataset has multiple tables in it. I want to write my own Update/Insert commands for the Dataadapter for each of the tables and not use the ones created by SqlCommandBuilder. The Update/Delete commands created by Command builder do not create where clause based on the primary key but the where cluase created will be based on all the columns. This...
3
2486
by: Jesse Liberty | last post by:
I created a new database (tried both in 2005 and in SQL 2000) and then created a SqlDataSource control in an asp.net application. Clicked on the smart tag and whose configure data source. When I click Advanced should see the Generate Insert, Update and Delete statements check box but it is grayed out. Any idea what might cause this? I can work around with this code, which does work: SqlDataSource1.InsertCommand = "Insert into myTable...
19
8359
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without FOR UPDATE, it is fine and no error. I also tried Set objRs = objConn.Execute("SELECT * FROM EMP UPDATE OF EMPNO"), but it still couldn't help. any ideas? I tried to search in the web but couldn't find similar
13
1874
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I am using VS2005. I created a Windows Appication project. Inside the Server Explorer, I created a new SQLExpress database, and then created a new table. I added the rows, making my first row an integer, and setting the identity property to true. I set that row to be my primary key. I then added a dataset, and added my table to the dataset. When I configure the table, I have no Update or Delete commands, even though the wizard has the...
0
1564
by: lianaent | last post by:
Hi All, I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can populate it dynamically by choosing from a dropdown that I populate dynamically from the database sys.tables table. When I choose a table from my dropdown, poof, the gridview is beautifully loaded with all the columns and rows, and the edit and delete...
13
8864
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single transaction. Does anyone have an SQL statement I can throw at it that would accomplish this? If I can't figure out how to do it, I'm going to have to send two discreet SQL commands for each record which will take infinitely longer than a...
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8174
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.