473,385 Members | 1,673 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,385 software developers and data experts.

MS Access LDB file (lock) and INSERT Failure

Hi,

I am writing a subscription page in C#. I first check if username is unique by

"SELECT UserName FROM Logins WHERE Username ='dadada'"

Then if unique, I create the user by

"INSERT INTO Logins
(UserName,UserType,Password,StartDate,Status,Email ,Phone,Home) VALUES
('dadada','u','dadadada',#8/25/2005 5:22:33
PM#,'trial','d@yhaoo.com','1231231231','10 brechk st., bridgewater, nj
08807')"

Somehow this always returns exception after running dbCmd.ExecuteNonQuery()
as below

"Syntax error in INSERT INTO statement."

I checked the syntax many times, could not find anything wrong.

When user logins in, I update the DB successfully as below:

"INSERT INTO Visits (Email,LoginDate,ReferPage,LoginOK,LoginPass,IP) VALUES
('admina',#8/25/2005 5:25:16
PM#,'/passwordProtectCSharp/privatePage.aspx',1,'adminabc','127.0.0.1')"

So access to DB is OK. I suspect my first reading to Logins table caused ldb
lock. So I can not insert afterwards. After removing the check of uniqueness,
I still have the same error.

Any suggestions? Thanks. -Dale
PS. ldb file sometimes stays there for a long time, sometimes it disappears
soon after code is stopped. can not delete it. any way to control it?

Nov 17 '05 #1
2 2605
Access automatically creates an ldb (lock file) when you open a connection
to it, and will only remove it after you close the connection, you never
need to delete it. Your sql statement will have a problem, either because
it's using a reserved word i.e. I think password is reserved, so if you have
a field called that wrap it in square brackets [password], so Access knows
it's a field, or else you're not meeting a field requirement e.g. your phone
number is 10 characters and you've only allowed for 8.

Please note you should always wrap database access code in either try-catch
or Using blocks to ensure that if there is an error the connection is
correctly closed.

Cathal
"dale zhang" <da*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Hi,

I am writing a subscription page in C#. I first check if username is unique by
"SELECT UserName FROM Logins WHERE Username ='dadada'"

Then if unique, I create the user by

"INSERT INTO Logins
(UserName,UserType,Password,StartDate,Status,Email ,Phone,Home) VALUES
('dadada','u','dadadada',#8/25/2005 5:22:33
PM#,'trial','d@yhaoo.com','1231231231','10 brechk st., bridgewater, nj
08807')"

Somehow this always returns exception after running dbCmd.ExecuteNonQuery() as below

"Syntax error in INSERT INTO statement."

I checked the syntax many times, could not find anything wrong.

When user logins in, I update the DB successfully as below:

"INSERT INTO Visits (Email,LoginDate,ReferPage,LoginOK,LoginPass,IP) VALUES ('admina',#8/25/2005 5:25:16
PM#,'/passwordProtectCSharp/privatePage.aspx',1,'adminabc','127.0.0.1')"

So access to DB is OK. I suspect my first reading to Logins table caused ldb lock. So I can not insert afterwards. After removing the check of uniqueness, I still have the same error.

Any suggestions? Thanks. -Dale
PS. ldb file sometimes stays there for a long time, sometimes it disappears soon after code is stopped. can not delete it. any way to control it?

Nov 17 '05 #2
Cathal,

Thank you very much. You are exactly right. Some words are reserved. I added
some of them with 1 at end. It is work fine now.

-Dale

"Cathal Connolly [VB MVP]" wrote:
Access automatically creates an ldb (lock file) when you open a connection
to it, and will only remove it after you close the connection, you never
need to delete it. Your sql statement will have a problem, either because
it's using a reserved word i.e. I think password is reserved, so if you have
a field called that wrap it in square brackets [password], so Access knows
it's a field, or else you're not meeting a field requirement e.g. your phone
number is 10 characters and you've only allowed for 8.

Please note you should always wrap database access code in either try-catch
or Using blocks to ensure that if there is an error the connection is
correctly closed.

Cathal
"dale zhang" <da*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Hi,

I am writing a subscription page in C#. I first check if username is

unique by

"SELECT UserName FROM Logins WHERE Username ='dadada'"

Then if unique, I create the user by

"INSERT INTO Logins
(UserName,UserType,Password,StartDate,Status,Email ,Phone,Home) VALUES
('dadada','u','dadadada',#8/25/2005 5:22:33
PM#,'trial','d@yhaoo.com','1231231231','10 brechk st., bridgewater, nj
08807')"

Somehow this always returns exception after running

dbCmd.ExecuteNonQuery()
as below

"Syntax error in INSERT INTO statement."

I checked the syntax many times, could not find anything wrong.

When user logins in, I update the DB successfully as below:

"INSERT INTO Visits (Email,LoginDate,ReferPage,LoginOK,LoginPass,IP)

VALUES
('admina',#8/25/2005 5:25:16
PM#,'/passwordProtectCSharp/privatePage.aspx',1,'adminabc','127.0.0.1')"

So access to DB is OK. I suspect my first reading to Logins table caused

ldb
lock. So I can not insert afterwards. After removing the check of

uniqueness,
I still have the same error.

Any suggestions? Thanks. -Dale
PS. ldb file sometimes stays there for a long time, sometimes it

disappears
soon after code is stopped. can not delete it. any way to control it?


Nov 17 '05 #3

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

Similar topics

14
by: deko | last post by:
Do I need to use flock() when reading a file into an array? It's possible that the file in question could be open at the time the file('filename') request is made. I realize flock() is required...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Gery D. Dorazio | last post by:
Here is some code to open a file with exclusive access for the purpose of modifying it. FileStream fstrm = new FileStream(inputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite,...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
2
by: adri4n | last post by:
as wat ive mentioned in the title.. im would like to know whether the a particular record/table is being locked in my program. some of the methods which i would like to develop are as below: ...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.