473,385 Members | 1,655 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.

update query in ms-access doesn't working


hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my 'update'
syntax.

I can successfully run other dbase operations like insertion, deletion
& all.; except Updation.

But, i can successfully run the same update query in the 'sql query
tab' of MS ACCESS, and is executed successfully.

I'm using VS.NET 2005 & MS ACCESS 2003.

please help me...its urgent.

i'm including the code below :

************************************************** ***************

string provider = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =
db1.mdb;";
string sql = "update Table1 set Password = 'modify' where ID =
'abhi'";

try
{
OleDbConnection oc = new OleDbConnection(provider);
OleDbCommand od = new OleDbCommand(sql, oc);
oc.Open();

od.ExecuteNonQuery();

oc.Close();
}
catch (Exception exp)
{
return exp.Message;
}

************************************************** ***************

My table contains two field : "ID" & "Password", both are of String
type.

************************************************** ***************

thanks in advance
Nov 24 '07 #1
5 3207
I'm not sure, but perhaps it is the quotes in the string (mabye it is
looking for a double-quote)?

I doubt that your string is a constant like that, but rather, a string
that you concatenate together. In this case, you should use a parameterized
query, and let the provider handle the parameter formatting issues for you.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ab************@gmail.comwrote in message
news:61**********************************@a39g2000 pre.googlegroups.com...
>
hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my 'update'
syntax.

I can successfully run other dbase operations like insertion, deletion
& all.; except Updation.

But, i can successfully run the same update query in the 'sql query
tab' of MS ACCESS, and is executed successfully.

I'm using VS.NET 2005 & MS ACCESS 2003.

please help me...its urgent.

i'm including the code below :

************************************************** ***************

string provider = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =
db1.mdb;";
string sql = "update Table1 set Password = 'modify' where ID =
'abhi'";

try
{
OleDbConnection oc = new OleDbConnection(provider);
OleDbCommand od = new OleDbCommand(sql, oc);
oc.Open();

od.ExecuteNonQuery();

oc.Close();
}
catch (Exception exp)
{
return exp.Message;
}

************************************************** ***************

My table contains two field : "ID" & "Password", both are of String
type.

************************************************** ***************

thanks in advance
Nov 24 '07 #2
ab************@gmail.com wrote:
hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my 'update'
syntax.

I can successfully run other dbase operations like insertion, deletion
& all.; except Updation.

But, i can successfully run the same update query in the 'sql query
tab' of MS ACCESS, and is executed successfully.
string provider = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =
db1.mdb;";
string sql = "update Table1 set Password = 'modify' where ID =
'abhi'";
Maybe password is a reserved word.

Try:

string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";

Arne

Nov 24 '07 #3
On 24 Nov, 16:57, Arne Vajhøj <a...@vajhoej.dkwrote:
abhilashcas...@gmail.com wrote:
hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my 'update'
syntax.
I can successfully run other dbase operations like insertion, deletion
& all.; except Updation.
But, i can successfully run the same update query in the 'sql query
tab' of MS ACCESS, and is executed successfully.
string provider = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =
db1.mdb;";
string sql = "update Table1 set Password = 'modify' where ID =
'abhi'";

Maybe password is a reserved word.

Try:

string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";

Arne
check if an @ might help... donno why but test string sql = @"update
Table1 set Password = 'modify' where ID = 'abhi'";
dont think password is reserved, but new to c#

//CY
Nov 25 '07 #4
ch*******@gmail.com wrote:
On 24 Nov, 16:57, Arne Vajhøj <a...@vajhoej.dkwrote:
>abhilashcas...@gmail.com wrote:
>>hi guys, my prblem is that I cannot update sql query against MS ACCESS
using C#. Everytime wen i do so, i got an exception (at runtime) as
'UPDATE syntax not correct'. I don find any error in my 'update'
syntax.
I can successfully run other dbase operations like insertion, deletion
& all.; except Updation.
But, i can successfully run the same update query in the 'sql query
tab' of MS ACCESS, and is executed successfully.
string provider = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =
db1.mdb;";
string sql = "update Table1 set Password = 'modify' where ID =
'abhi'";
Maybe password is a reserved word.

Try:

string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";

check if an @ might help... donno why but test string sql = @"update
Table1 set Password = 'modify' where ID = 'abhi'";
The @ should not have any impact here - no \ characters.
dont think password is reserved
http://support.microsoft.com/kb/248738 claims it is.

Arne
Nov 25 '07 #5
>
dont think password is reserved

http://support.microsoft.com/kb/248738claims it is.

Arne- Dölj citerad text -

- Visa citerad text -
I stand corrected, was thinking just C#, not access

//CY

Nov 25 '07 #6

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

Similar topics

1
by: Jochen Daum | last post by:
Hi ! I have this upate statement which gets sent to MS SQL: update MsgOutgoing set SenderResource = NULL,RecipientAddress = 'xxxxxxxxx',EarliestSentDateTime = NULL,LatestSentDateTime =...
3
by: Michel | last post by:
Hi All, In Oracle, I can easily make this query : UPDATE t1 SET (f1,f2)=(SELECT AVG(f3),SUM(f4) FROM t2 WHERE t2.f5=t1.f6) WHERE f5='Something' I cannot seem to be able to do the same...
4
by: Karaoke Prince | last post by:
Hi There, I have an update statement to update a field of a table (~15,000,000 records). It took me around 3 hours to finish 2 weeks ago. After that no one touched the server and no...
10
by: R Camarda | last post by:
I have the following statement that takes quite a long time. Longest of any of my SQL statment updates. UPDATE F_REGISTRATION_STD_SESSION SET PREVIOUS_YEAR_SESSION_ID = ( SELECT...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
3
by: Riley DeWiley | last post by:
Using OLEDB, Jet 4.0, C++, Windows. I have been baffled by UPDATE queries that return S_OK but do not change the data in the database. It seems that UPDATEs do not update until the CDataSource...
0
by: David Linsin | last post by:
I created a simple test case to reproduce the problem (also check Bug #15500): import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;...
2
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
2
by: justapawn | last post by:
Can someone assist me in using the correct syntax or method of assigning a variable to the Set portion of a DoCmd.RunSQL Update Query? The help file and most sites, including ms, seem to think the...
13
by: Neil | last post by:
I'm running an update query in SQL 7 from QA, and it runs forever. Has been running for 20 minutes so far! The query is quite simple: update a single field in a table, based on a join with another...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.