I have checked my return strings and all are correct. But when I want to
insert them into an Access database table it fails. However, if I change the
insert values just to simple strings it works. Yet I have all the
aryItemFields[i] values as strings correctly. Any HINT>>>>PLEASE.
...(THIS PIECE OF CODE DOES NOT WORK.....). ...
aryItemFields[0] = fielInfo.fileName;
aryItemFields[1] = fielInfo.size.ToString();
aryItemFields[2] = fielInfo.creationTime.ToString();
aryItemFields[3] = fielInfo.lastAccessTime.ToString();
myOleCommand = new OleDbCommand("INSERT INTO mytable1
filename,fsize,fcreationTime,fAccessTime) ValuesaryItemFields[0]
,aryItemFields[1],aryItemFields[2],aryItemFields[3])", myConnection);
(HOWEVER THIS ONE WORKS FINE......)
myOleCommand = new OleDbCommand("INSERT INTO mytable1
filename,fsize,fcreationTime,fAccessTime) Values('a','b','c','d')",
myConnection); 2 11127
Well, the key point is the presence of the single quotes in the statement
that works. Do the same on your real data, such as:
aryItemFields[1] = "'" + fielInfo.size.ToString() + "'";
for all fields that are defined as one of the string types in the column
definitions, and you'll be on your way.
Tom Dacon
Dacon Software Consulting
"JH" <yh*******@yahoo.com> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl... I have checked my return strings and all are correct. But when I want to insert them into an Access database table it fails. However, if I change the insert values just to simple strings it works. Yet I have all the aryItemFields[i] values as strings correctly. Any HINT>>>>PLEASE.
..(THIS PIECE OF CODE DOES NOT WORK.....). ... aryItemFields[0] = fielInfo.fileName;
aryItemFields[1] = fielInfo.size.ToString();
aryItemFields[2] = fielInfo.creationTime.ToString();
aryItemFields[3] = fielInfo.lastAccessTime.ToString();
myOleCommand = new OleDbCommand("INSERT INTO mytable1 filename,fsize,fcreationTime,fAccessTime) ValuesaryItemFields[0] ,aryItemFields[1],aryItemFields[2],aryItemFields[3])", myConnection);
(HOWEVER THIS ONE WORKS FINE......)
myOleCommand = new OleDbCommand("INSERT INTO mytable1 filename,fsize,fcreationTime,fAccessTime) Values('a','b','c','d')", myConnection);
You need to use parameterized queries:
myOleCommand = new OleDbCommand("INSERT INTO mytable1
(filename,fsize,fcreationTime,fAccessTime) VALUES (?,?,?,?");
myOleCommand.Parameters.Add("@filename",OleDbType. Whatever).Value =
aryItemFields[0];
// etc.
--Bob
"JH" <yh*******@yahoo.com> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl... I have checked my return strings and all are correct. But when I want to insert them into an Access database table it fails. However, if I change the insert values just to simple strings it works. Yet I have all the aryItemFields[i] values as strings correctly. Any HINT>>>>PLEASE.
..(THIS PIECE OF CODE DOES NOT WORK.....). ... aryItemFields[0] = fielInfo.fileName;
aryItemFields[1] = fielInfo.size.ToString();
aryItemFields[2] = fielInfo.creationTime.ToString();
aryItemFields[3] = fielInfo.lastAccessTime.ToString();
myOleCommand = new OleDbCommand("INSERT INTO mytable1 filename,fsize,fcreationTime,fAccessTime) ValuesaryItemFields[0] ,aryItemFields[1],aryItemFields[2],aryItemFields[3])", myConnection);
(HOWEVER THIS ONE WORKS FINE......)
myOleCommand = new OleDbCommand("INSERT INTO mytable1 filename,fsize,fcreationTime,fAccessTime) Values('a','b','c','d')", myConnection);
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marko Poutiainen |
last post by:
Situation:
We had to make our SQLServer 2000 database multi-lingual. That is, certain
things (such as product names) in the database should be shown in the
language the user is using (Finnish,...
|
by: Joachim Klassen |
last post by:
Hi all,
first apologies if this question looks the same as another one I recently
posted - its a different thing but for the same szenario:-).
We are having performance problems when...
|
by: Charles Wilt |
last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access
via a linked server from SQL Server 2000.
The following select works fine:
select * from...
|
by: c676228 |
last post by:
Hi everyone,
I am just wodering in asp program, if there is anybody writing store
procedure for inserting data into database since there are so many parameters
need to be passed into store...
|
by: rcoco |
last post by:
Hi,
I want to share this problem. I have a datagrid that will help me
Insert data into sql database. So I made a button On my form so that
when I press the button a new row on datagrid should be...
|
by: Etayki |
last post by:
Hi!
I am trying to insert data into a MS SQL Database from a Console
Application written in VB.net
I have already created the table in the database and I am able to read
values. When I insert a...
|
by: dos360 |
last post by:
Hello,
I have two tables, one is a list of activities, the other a list of
participants. I want to insert one record in the activities table and
then using its identity column as foreign key, I...
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography...
|
by: cluce |
last post by:
I am trying to read a csv file with user info (username, password, email, address, city, zip, state, etc.) I am inserting the username, password, email into the aspnet_memberhsip table using the...
|
by: billelev |
last post by:
I have a large array of data (1000 x 40 x 3) that I am inserting into a database table. It is incredibly slow, and so I was wondering if there is a quicker way of inserting array data into a table....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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: 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...
| |