473,770 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copying records

I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff

May 5 '06 #1
6 1402
Jeff,

If is an easy question however has not a simple answer. If the keys of those
records are for sure completely unique, than it is simple.

Create a SQL Insertcommand with parameters and let it run by using an
ExecuteNonQuery

Because almost all text for OleDb parameters on MSDN are wrong. I give you
this, which is in my opinion one of the correct once. (OleDB uses no named
parameters which is consequent used on MSDN).

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

I hope this helps,

Cor

"Jeff Brooks" <Je********@dis cussions.micros oft.com> schreef in bericht
news:7B******** *************** ***********@mic rosoft.com...
I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to
get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff

May 5 '06 #2
Cor,

Thanks for the reply. I have used the execnonquery before. It works great,
but I was really hoping to get away from having to build a large insert
command. I was hoping to just copy the dataset and modify the fields I need
modified.
Jeff
"Cor Ligthert [MVP]" wrote:
Jeff,

If is an easy question however has not a simple answer. If the keys of those
records are for sure completely unique, than it is simple.

Create a SQL Insertcommand with parameters and let it run by using an
ExecuteNonQuery

Because almost all text for OleDb parameters on MSDN are wrong. I give you
this, which is in my opinion one of the correct once. (OleDB uses no named
parameters which is consequent used on MSDN).

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

I hope this helps,

Cor

"Jeff Brooks" <Je********@dis cussions.micros oft.com> schreef in bericht
news:7B******** *************** ***********@mic rosoft.com...
I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to
get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff


May 5 '06 #3
Jeff,

You can and when you have less than 100 fields you can even use a
commanbuilder to build the insert.

First you have than to set a schema in a new dataset using the Fileschema
Than you create a dataadapter

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

Fill that with your data in the way you wish.
and use than the commanbuilder

dim cmb = oledbcommandbui lder(TheDataAda pter)

And than the update.

I hope this helps,

Cor

"Jeff Brooks" <Je********@dis cussions.micros oft.com> schreef in bericht
news:CF******** *************** ***********@mic rosoft.com...
Cor,

Thanks for the reply. I have used the execnonquery before. It works
great,
but I was really hoping to get away from having to build a large insert
command. I was hoping to just copy the dataset and modify the fields I
need
modified.
Jeff
"Cor Ligthert [MVP]" wrote:
Jeff,

If is an easy question however has not a simple answer. If the keys of
those
records are for sure completely unique, than it is simple.

Create a SQL Insertcommand with parameters and let it run by using an
ExecuteNonQuery

Because almost all text for OleDb parameters on MSDN are wrong. I give
you
this, which is in my opinion one of the correct once. (OleDB uses no
named
parameters which is consequent used on MSDN).

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

I hope this helps,

Cor

"Jeff Brooks" <Je********@dis cussions.micros oft.com> schreef in bericht
news:7B******** *************** ***********@mic rosoft.com...
>I need to copy a record one access record into the same table. I just
>need
> to modify a couple fields that the user will change. Im sure there is
> an
> easy way to do it. I have started just reading the data and writing a
> SQL
> insert command, but there are a ton of fields. It would take forever
> to
> get
> the datatypes correct and the SQL formatted properly. Anyone know how
> to
> just copy a record and make a couple changes to it?
>
> Thanks
> Jeff
>


May 5 '06 #4
You can use the insert command to read from the table. Example:

insert into table (field1, field2, field3)
select field1, field2, 42 from table where field3 = 18

This way you ony have to supply the values that you want to change, and
just copy the unchanged values.

Jeff Brooks wrote:
I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff

May 5 '06 #5
I was hoping I could get away from that. It will be a long insert statement.

"Göran Andersson" wrote:
You can use the insert command to read from the table. Example:

insert into table (field1, field2, field3)
select field1, field2, 42 from table where field3 = 18

This way you ony have to supply the values that you want to change, and
just copy the unchanged values.

Jeff Brooks wrote:
I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff

May 5 '06 #6
I am extremely new to vb but i do something in my other language i program
in that i will soon try to re-create in vb.

Basically we have a file such as dbf with 100+ fields.

We have a function that we call and it Loops through the file defenition (
knowing now how many fields there are in a record ).
We call this "Scatter() ""
Scatter looks at the record you are sitting on, loops through the field
names ( that you know from the dbf defenition ) and then
writes each field into an array. So a Record that has 115 fields would have
115 dimension arrays.

So now this function returns the array of all the values in the field.

Now we have another function called " Gather() " and this loops through the
array copying all the values in the array to
the same field # in the database.

In between calling Scatter and Gather, you can change values in an array.
You just have to know which array# you are changin,
which is the field # in the db.

Once i get to this stage ill try to write it in vb. See me in a month or
two ;)
I had a big enough problem last night trying to call one form from another.

Miro.
"Jeff Brooks" <Je********@dis cussions.micros oft.com> wrote in message
news:7B******** *************** ***********@mic rosoft.com...
I need to copy a record one access record into the same table. I just need
to modify a couple fields that the user will change. Im sure there is an
easy way to do it. I have started just reading the data and writing a SQL
insert command, but there are a ton of fields. It would take forever to
get
the datatypes correct and the SQL formatted properly. Anyone know how to
just copy a record and make a couple changes to it?

Thanks
Jeff

May 8 '06 #7

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

Similar topics

3
2668
by: Jason | last post by:
In enterprise manager I am copying a table from one database to another. I am using the dts wizard to import the data. After I successfully import the data, I open both tables to compare the records to make sure they are the same. I right click on a field and click "last" for both tables. However, the record is different for both. If I do a query the record is still there but they do not show up in the same order. Why does'nt the...
1
1146
by: John | last post by:
Hi I need to copy new records from an access table which can potentially have records added to it all the time by users. I figure I can add a flag for records that have been copied already that can be set after copy. The problem is that in the time that I copy all new records using 'select * from ... where not flag' and coming back to update flags for all records not already flagged, new records could have been entered by the users which...
1
1400
by: Jimbo | last post by:
Hi Guys, I'm hoping one of you will give me a leg up with a problem Im having, which I think is possible to do. Let me explain. I have 2 tables and 1 form - ie 'tableDigit', 'tableNumber' and 'formDigit'. 'tableDigit' has 2 fields - ie 'digit1' and 'digit2', 'formDigit' is used to input data to 'tableDigit'. 'tableNumber' has 1 field - ie 'Number'
5
2467
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'") temptable.Clear() For Each row As DataRow In temprows temptable.Rows.Add(row) Next
8
3359
by: daD | last post by:
I'm trying to write a small database that tracks people coming and going from a small campground. I need to have the current guests in the "current" table" and then have the ability to check them out to the "archive" table when they leave, by pushing the "check-out" button. I see the steps as follows: 1. When the check-out button is pressed, the computer should automatically add the current date into the "date checked-out" field. ...
38
1815
by: Rex | last post by:
In a table, I have number of records belonging to a particular ID now if I enter a value in one of the fileds of this table I want it to be copied in all the records belonging to this particluar ID. for example ID Name -------------------------- 1 xyz 1 1 1
1
1326
by: francesllee | last post by:
I'm having problems copying subreports when copying a report. Is there an easy way to do this? My childlink is not a AutoNumber but it is a number (which should make is simpler). I just want to set the childlink to a 0. The keys are the primary keys. Parent: tTransmittal: TX, Operation, OperationDate, Address, Key1 Child: tData: TX, Data, Classification, Link, Key2 GrandChild?: Link, Description, Media, LogNumber, Key3 Thank you...
1
1021
by: cmrhema | last post by:
Hi, I have two tables emp and empcheck1 in the same database emp consits 50 records and empcheck1 consists of 25 records Both the tables have the same design, here empid is the unique key I want to insert all the datas from emp1 to empcheck1 in such a way that it should not rewrite or duplicate the original 25 records
2
2392
by: troy_lee | last post by:
What is the best way of copying all the records from a linked table into a replica table that is local on my computer? This is for development work at home where I can not access the main table. Is a macro the best way to handle this? Thanks in advance. Troy Lee
0
1283
by: ElishaThompson | last post by:
I recently had a problem requiring me to locate and copy all records pertaining to a particular client from numerous tables in a database on a given server to tables within an identical database on another server. In essence; Given a particular ClientID (primary key in a top-of-the-hierarchy table), I needed to be able to obtain all records in all tables (maintaining referential integrity) that pertain to the particular ClientID and copy...
0
9454
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
10101
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
10038
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
9906
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...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.