473,666 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem inserting to an Access database

Hi All,

The following piece of code is what I have tried to update a simple
Access database (none of the commented out code worked either). The
connection to the database seems to be fine because I am able to read
data from it. However, when trying to add another row of data, nothing
seems to happen.

I have also checked the permissions in IIS and they seem to be set up
fine.

Any ideas would be much appreciated.

Regards,
Alan

<%@LANGUAGE = PerlScript%>

<%
use Win32::OLE;
use Win32::OLE::Con st 'Microsoft ActiveX Data Objects';

$Conn = Win32::OLE->new("ADODB.Con nection");
$RS = Win32::OLE->new("ADODB.Rec ordset");

$DBFile = "E:\\vhosts\\in ternaltest\\pub lic_html\\ITRte st.mdb";

$DSN = "PROVIDER=MSDAS QL;DRIVER={Micr osoft Access Driver (*.mdb)};
DBQ=$DBFile;UID =;PWD=;";

$Conn->Open($DSN);

$RS->Open("test", $Conn, adLockOptimisti c, adOpenDynamic);

$fields = ["barcode", "desc"];
$values = ["C999", "this"];

$RS->AddNew($fields , $values);

#$Conn->Open("INSERT INTO test VALUES ('aaa', 'bbb')");
#$RS->Open($SQL, $Conn, 1, 1);

#$SQL = 'insert into test (barcode) VALUES "C999"';
#$RS = $Conn->Execute($SQL );

#$RS->AddNew;
#$RS->Fields('barcod e')->{value} = "ABC";
#$RS->Update;
$RS->Close;
$Conn->Close;
%>
Nov 12 '05 #1
3 2306
I had problems with AddNew method; for some wierd reason I couldn't make
it work with lists of fields. I ended up looping through the fields.
Have you tried to use the same SQL and VBA code directly in the DB? Is
the other field than Barcode required and not autonumber?
Pavel

Alan Chiew wrote:

Hi All,

The following piece of code is what I have tried to update a simple
Access database (none of the commented out code worked either). The
connection to the database seems to be fine because I am able to read
data from it. However, when trying to add another row of data, nothing
seems to happen.

I have also checked the permissions in IIS and they seem to be set up
fine.

Any ideas would be much appreciated.

Regards,
Alan

<%@LANGUAGE = PerlScript%>

<%
use Win32::OLE;
use Win32::OLE::Con st 'Microsoft ActiveX Data Objects';

$Conn = Win32::OLE->new("ADODB.Con nection");
$RS = Win32::OLE->new("ADODB.Rec ordset");

$DBFile = "E:\\vhosts\\in ternaltest\\pub lic_html\\ITRte st.mdb";

$DSN = "PROVIDER=MSDAS QL;DRIVER={Micr osoft Access Driver (*.mdb)};
DBQ=$DBFile;UID =;PWD=;";

$Conn->Open($DSN);

$RS->Open("test", $Conn, adLockOptimisti c, adOpenDynamic);

$fields = ["barcode", "desc"];
$values = ["C999", "this"];

$RS->AddNew($fields , $values);

#$Conn->Open("INSERT INTO test VALUES ('aaa', 'bbb')");
#$RS->Open($SQL, $Conn, 1, 1);

#$SQL = 'insert into test (barcode) VALUES "C999"';
#$RS = $Conn->Execute($SQL );

#$RS->AddNew;
#$RS->Fields('barcod e')->{value} = "ABC";
#$RS->Update;

$RS->Close;
$Conn->Close;
%>

Nov 12 '05 #2
On Wed, 24 Sep 2003 09:35:18 -0600, Pavel Romashkin
<pa************ *@hotmail.com> wrote:
I had problems with AddNew method; for some wierd reason I couldn't make
it work with lists of fields. I ended up looping through the fields.
Have you tried to use the same SQL and VBA code directly in the DB? Is
the other field than Barcode required and not autonumber?
Pavel


Hi Pavel,

I have tried the SQL code in the DB and it works fine. The other
field, desc, is just another text field and is not required.

Cheers,
Alan
Nov 12 '05 #3
I don't know what to suggest. Looks to me that executing SQL should have
worked. Try re-posting your original problem again - maybe someone will
have a better idea.
Good luck,
Pavel

Alan Chiew wrote:

On Wed, 24 Sep 2003 09:35:18 -0600, Pavel Romashkin
<pa************ *@hotmail.com> wrote:
I had problems with AddNew method; for some wierd reason I couldn't make
it work with lists of fields. I ended up looping through the fields.
Have you tried to use the same SQL and VBA code directly in the DB? Is
the other field than Barcode required and not autonumber?
Pavel


Hi Pavel,

I have tried the SQL code in the DB and it works fine. The other
field, desc, is just another text field and is not required.

Cheers,
Alan

Nov 12 '05 #4

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

Similar topics

3
6106
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection Timed out) I am using the Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000. In there first question there can be up to 27 answers. So I figured instead of making 27 different trips to the database I woulc just concatenate my...
7
3425
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL database. What would be a low-cost method I could use inside this console application to make sure the MS SQL database is operational before I perform the insert?
1
2027
by: Erica | last post by:
Hi, I have searched everywhere, and I can't seem to find the answer to my problem. I am trying to write a very simple piece of ASP code to insert a record into a field in a database. Ultimately it will be for an admin form that takes user input, but for now I just want to get the most intrinsic part working. This is the code: <% ' Declare variables Dim strURL ' The URL of this page so the form will work no matter
15
4103
by: yzlin04 | last post by:
Hello, I'm new in vb.net. I have a problem in inserting a new row to a MS Access database table. There is no error message comes out when i run my program, but when i check my MS Access table, there is no record inserted. So, i don't know which line is incorrect. Here is my code: Dim desc, itemID As String itemID = txtItemID.Text desc = txtItemDesc.Text
3
3353
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert records to a data base,for which i am using Typed dataSet.(I used DataSet Designer to create one) Then created a table adapter in which i have written query for INSERT , & set Database Direct property to true.(I didnt use a seperate methods for...
20
3010
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt file is to be read into my java program and then inserted (from the program into an Access Database). I am not exactly sure of where the problem lies. I know it has something to do with how I am parsing the file, or how I am passing my arguments to...
0
1644
by: SL Culby | last post by:
Hello everyone, I have a project where I pull SQL Server data put it into a dataset and now I have to put the dataset data into an Access Database. The dataset currently is over 2000 row, so looping through and inserting one row at a time is very expensive. Does anyone know a fast way with low overhead to accomplish this task. I have been working in this direction (code below) however the code inserts 0 rows into the access database. ...
6
11756
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the contents of the form is inserted into the MS Access database. The Customer table in the database already has 30 records (with CustomerIDs 1 - 30) in it (from when the database was first created). The CustomerID field in the database is an...
2
3075
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 section: Discography --------------------- DiscID
2
3111
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate record. My code inserts records one by one using addnew-updatebatch. If there is a duplicate in the db, it will display "already exists" and if it is not in the db it will display "record added". Below is my asp code I found on the net and...
0
8360
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
8876
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...
1
8556
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
8642
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
7387
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...
1
6198
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
5666
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
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2774
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

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.