473,416 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Access Table Load

I'm using a VB.Net interface to load an Access table. The relationship is 1
input record to many table rows. The problem is that the first name of the
first row is populated for every row on the table (which curiously has the
correct total number of rows for the input file!). The reader does read the
data correctly.

If I put all the input record data into one row, it works perfectly.

Here's the partial code:

Dim objData as New DALBase
objData.SQL = "usp_LoadImportTable"
objData.InitializeCommand()

Line = objReader.ReadLine

' Code to read the input file and split the data into the desired fields -
works great.

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName1)
Call LoadTable()

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName2)

Private Sub LoadTable()
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
' Error Handling
objData.CloseConnection()
End Sub

The Access SQL command "usb_LoadImportTable" is very simple:
INSERT INTO TempTable ID, Name FROM @ID, @NAME;

I figure that I need to clear the objData settings between the various
iterations of the input record, but everything I have tried has failed.

If the code extract isn't clear, I can email the actual Notepad file.

Nov 23 '05 #1
3 1987
Roy,

You are using complex code for a simple problem. Why don't you first try it
with direct code.
Not Stored Procedures
No parameters
etc.

If it works than you can piece by piece change it in the code it has to be
and than in the way as you did, because the principle is right.

This in the context of. It is better to learn somebody how to fish than give
him fish.

I hope this helps,

Cor
"roy_ware" <ro*****@discussions.microsoft.com> schreef in bericht
news:C9**********************************@microsof t.com...
I'm using a VB.Net interface to load an Access table. The relationship is
1
input record to many table rows. The problem is that the first name of
the
first row is populated for every row on the table (which curiously has the
correct total number of rows for the input file!). The reader does read
the
data correctly.

If I put all the input record data into one row, it works perfectly.

Here's the partial code:

Dim objData as New DALBase
objData.SQL = "usp_LoadImportTable"
objData.InitializeCommand()

Line = objReader.ReadLine

' Code to read the input file and split the data into the desired
fields -
works great.

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName1)
Call LoadTable()

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName2)

Private Sub LoadTable()
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
' Error Handling
objData.CloseConnection()
End Sub

The Access SQL command "usb_LoadImportTable" is very simple:
INSERT INTO TempTable ID, Name FROM @ID, @NAME;

I figure that I need to clear the objData settings between the various
iterations of the input record, but everything I have tried has failed.

If the code extract isn't clear, I can email the actual Notepad file.

Nov 23 '05 #2
I hate to admit it, but I don't know how to do it inline.......
"Cor Ligthert [MVP]" wrote:
Roy,

You are using complex code for a simple problem. Why don't you first try it
with direct code.
Not Stored Procedures
No parameters
etc.

If it works than you can piece by piece change it in the code it has to be
and than in the way as you did, because the principle is right.

This in the context of. It is better to learn somebody how to fish than give
him fish.

I hope this helps,

Cor
"roy_ware" <ro*****@discussions.microsoft.com> schreef in bericht
news:C9**********************************@microsof t.com...
I'm using a VB.Net interface to load an Access table. The relationship is
1
input record to many table rows. The problem is that the first name of
the
first row is populated for every row on the table (which curiously has the
correct total number of rows for the input file!). The reader does read
the
data correctly.

If I put all the input record data into one row, it works perfectly.

Here's the partial code:

Dim objData as New DALBase
objData.SQL = "usp_LoadImportTable"
objData.InitializeCommand()

Line = objReader.ReadLine

' Code to read the input file and split the data into the desired
fields -
works great.

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName1)
Call LoadTable()

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName2)

Private Sub LoadTable()
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
' Error Handling
objData.CloseConnection()
End Sub

The Access SQL command "usb_LoadImportTable" is very simple:
INSERT INTO TempTable ID, Name FROM @ID, @NAME;

I figure that I need to clear the objData settings between the various
iterations of the input record, but everything I have tried has failed.

If the code extract isn't clear, I can email the actual Notepad file.


Nov 23 '05 #3
Roy,
OleDb parameters aren't named the way SQL parameters are. They are just
? characters and the parameters must be added to the command in the order
they appear in the SQL text.
Also the insert command would be
INSERT INTO TempTable (ID, Name) Values (?, ?);
using standard SQL syntax.
If you are using an Access Query your parameters probably have different
names than you are expecting. I think that you need to include the
enclosing square brackets in the parameter names.
You might get better answers in microsoft.public.dotnet.framework.adonet
which is dedicated to data access.

Ron Allen
"roy_ware" <ro*****@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
I'm using a VB.Net interface to load an Access table. The relationship is
1
input record to many table rows. The problem is that the first name of
the
first row is populated for every row on the table (which curiously has the
correct total number of rows for the input file!). The reader does read
the
data correctly.

If I put all the input record data into one row, it works perfectly.

Here's the partial code:

Dim objData as New DALBase
objData.SQL = "usp_LoadImportTable"
objData.InitializeCommand()

Line = objReader.ReadLine

' Code to read the input file and split the data into the desired
fields -
works great.

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName1)
Call LoadTable()

objData.AddParameter("@ID", OleDb.OleDbType.VarChar, 10, strID)
objData.AddParameter("@Name", OleDb.OleDbType.VarChar, 50, strName2)

Private Sub LoadTable()
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
' Error Handling
objData.CloseConnection()
End Sub

The Access SQL command "usb_LoadImportTable" is very simple:
INSERT INTO TempTable ID, Name FROM @ID, @NAME;

I figure that I need to clear the objData settings between the various
iterations of the input record, but everything I have tried has failed.

If the code extract isn't clear, I can email the actual Notepad file.

Nov 23 '05 #4

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

Similar topics

11
by: Bruce A. Julseth | last post by:
Newbie Question: Is there a way to import MS Access into MySQL? Maybe create a CSV or something. If so, what would be the SQL to do this? Thanks... Bruce
11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
3
by: Prince Kumar | last post by:
When running LOAD with "ALLOW READ ACCESS", I get the following error if select is running againt the table (isolation UR). load.sql --------- db2 load from /u02/data/dly_d040817_test.dat of...
5
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL...
6
by: fumanchu | last post by:
I've got to let end users (really just one person) load billing batch files into a third party app table. They need to specify the billing cycle name, the batch name, and the input file name and...
6
by: StepUP | last post by:
I'm a long time developer in Access. Noticing the "Why do IT guys hate MS Access?" thread made me think of my recent experiences in experimenting with VB .Net, and specifically, the Datagrid...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
4
by: CPD | last post by:
From PHP, doing a DROP TABLE and a CREATE TABLE is successful, but doing a LOAD FILE keeps failing, with the error "Access denied for user 'db_user'@'localhost' (using password: YES)". The...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
6
by: onnodb | last post by:
Hi all, While working on an Access UI to a MySQL database (which should be a reasonable, low-cost, flexible interface to the DB, better than web-based, much less costly than a full-fledged .NET...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.