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

Error while Upating Record

Hi,

I am trying to update a record in the DB and i am using OLEDB command and
connection.
I get this error while updating.

Error inserting data: System.Data.OleDb.OleDbException: Syntax error in
UPDATE statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Customer.InventoryDatabase.UpdateLogin(String uNamee, String pwde,
String accesse) in
C:\Inetpub\wwwroot\HP\Customer\Management\Inventor yDatabase.vb:line 51\r\n

Can anyone please suggest what this means,
this is my function that I an using to update the database (MS access)
Public Function Update(ByVal uName As String, ByVal pwd As String, ByVal
access As String) As Boolean
Dim CmdText As String = "UPDATE Login SET Password=@Password,
Access=@Access WHERE UName=@UName"
Dim cmd As New OleDbCommand(CmdText, conn)
Try
cmd.CommandType = CommandType.Text
cmd.CommandType = CommandType.Text

Dim pms As OleDbParameterCollection = cmd.Parameters
pms.Add("@UName", OleDbType.VarChar, 15)
pms.Add("@Password", OleDbType.VarChar, 15)
pms.Add("@Access", OleDbType.VarChar, 5)

pms("@UName").Value = uName
pms("@Password").Value = pwd
pms("@Access").Value = access

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Return True

Catch ex As Exception
logFile.LogOutput("Error inserting data: " + ex.ToString())
Return False

End Try
End Function

Thanks,

Stephen
Nov 18 '05 #1
3 1092
What working existing UPDATE code are you trying to modify? I assume you
have test code working?

I've never seen parameters set like that that for a direct SQL statement
personally. Stored procedures, yes. I thought that parameter replacements
within inline SQL required question marks?

Jeff

"Stephen" <st*********@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Hi,

I am trying to update a record in the DB and i am using OLEDB command and
connection.
I get this error while updating.

Error inserting data: System.Data.OleDb.OleDbException: Syntax error in
UPDATE statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Customer.InventoryDatabase.UpdateLogin(String uNamee, String pwde,
String accesse) in
C:\Inetpub\wwwroot\HP\Customer\Management\Inventor yDatabase.vb:line 51\r\n

Can anyone please suggest what this means,
this is my function that I an using to update the database (MS access)
Public Function Update(ByVal uName As String, ByVal pwd As String, ByVal
access As String) As Boolean
Dim CmdText As String = "UPDATE Login SET Password=@Password,
Access=@Access WHERE UName=@UName"
Dim cmd As New OleDbCommand(CmdText, conn)
Try
cmd.CommandType = CommandType.Text
cmd.CommandType = CommandType.Text

Dim pms As OleDbParameterCollection = cmd.Parameters
pms.Add("@UName", OleDbType.VarChar, 15)
pms.Add("@Password", OleDbType.VarChar, 15)
pms.Add("@Access", OleDbType.VarChar, 5)

pms("@UName").Value = uName
pms("@Password").Value = pwd
pms("@Access").Value = access

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Return True

Catch ex As Exception
logFile.LogOutput("Error inserting data: " + ex.ToString())
Return False

End Try
End Function

Thanks,

Stephen

Nov 18 '05 #2
I never use Access, but thought I read somewhere it doesn't take named
parameters, and that you need to use ?'s.

Bill

"Stephen" wrote:
Hi,

I am trying to update a record in the DB and i am using OLEDB command and
connection.
I get this error while updating.

Error inserting data: System.Data.OleDb.OleDbException: Syntax error in
UPDATE statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Customer.InventoryDatabase.UpdateLogin(String uNamee, String pwde,
String accesse) in
C:\Inetpub\wwwroot\HP\Customer\Management\Inventor yDatabase.vb:line 51\r\n

Can anyone please suggest what this means,
this is my function that I an using to update the database (MS access)
Public Function Update(ByVal uName As String, ByVal pwd As String, ByVal
access As String) As Boolean
Dim CmdText As String = "UPDATE Login SET Password=@Password,
Access=@Access WHERE UName=@UName"
Dim cmd As New OleDbCommand(CmdText, conn)
Try
cmd.CommandType = CommandType.Text
cmd.CommandType = CommandType.Text

Dim pms As OleDbParameterCollection = cmd.Parameters
pms.Add("@UName", OleDbType.VarChar, 15)
pms.Add("@Password", OleDbType.VarChar, 15)
pms.Add("@Access", OleDbType.VarChar, 5)

pms("@UName").Value = uName
pms("@Password").Value = pwd
pms("@Access").Value = access

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Return True

Catch ex As Exception
logFile.LogOutput("Error inserting data: " + ex.ToString())
Return False

End Try
End Function

Thanks,

Stephen

Nov 18 '05 #3
you are correct. the oledb driver (even if accessing sqlserver) only
supports "?" parameters.

-- bruce (sqlwork.com)
"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
| I never use Access, but thought I read somewhere it doesn't take named
| parameters, and that you need to use ?'s.
|
| Bill
|
| "Stephen" wrote:
|
| > Hi,
| >
| > I am trying to update a record in the DB and i am using OLEDB command
and
| > connection.
| > I get this error while updating.
| >
| > Error inserting data: System.Data.OleDb.OleDbException: Syntax error in
| > UPDATE statement.
| > at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
| > hr)
| > at
| >
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
| > dbParams, Object& executeResult)
| > at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
| > executeResult)
| > at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
| > behavior, Object& executeResult)
| > at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
| > behavior, String method)
| > at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
| > at Customer.InventoryDatabase.UpdateLogin(String uNamee, String pwde,
| > String accesse) in
| > C:\Inetpub\wwwroot\HP\Customer\Management\Inventor yDatabase.vb:line
51\r\n
| >
| > Can anyone please suggest what this means,
| > this is my function that I an using to update the database (MS access)
| > Public Function Update(ByVal uName As String, ByVal pwd As String, ByVal
| > access As String) As Boolean
| > Dim CmdText As String = "UPDATE Login SET Password=@Password,
| > Access=@Access WHERE UName=@UName"
| > Dim cmd As New OleDbCommand(CmdText, conn)
| > Try
| > cmd.CommandType = CommandType.Text
| > cmd.CommandType = CommandType.Text
| >
| > Dim pms As OleDbParameterCollection = cmd.Parameters
| > pms.Add("@UName", OleDbType.VarChar, 15)
| > pms.Add("@Password", OleDbType.VarChar, 15)
| > pms.Add("@Access", OleDbType.VarChar, 5)
| >
| > pms("@UName").Value = uName
| > pms("@Password").Value = pwd
| > pms("@Access").Value = access
| >
| > conn.Open()
| > cmd.ExecuteNonQuery()
| > conn.Close()
| > Return True
| >
| > Catch ex As Exception
| > logFile.LogOutput("Error inserting data: " + ex.ToString())
| > Return False
| >
| > End Try
| > End Function
| >
| > Thanks,
| >
| > Stephen
| >
| >
| >
Nov 18 '05 #4

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

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
3
by: Victor | last post by:
I'm trying to run this java program, but somehow the program always quit w/o giving any error msg at all. it happenned inside the first case statements. Strangely, after printing happen2, it just...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
2
by: cr55 | last post by:
I was wondering if anyone can help me with this programming code as i keep getting errors and am not sure how to fix them. The error code displayed now is error: C2228: left of '.rent' must have...
2
by: jthep | last post by:
I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this? The function...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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.