Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

Update MS Access from vb .net fails to stick

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JeremyGrand - 16 May 2005 22:27 GMT
This is reposted from the vb forum since a couple of folks there thought it
was more suited to this forum.

When I execute the following, it finishes without error (return value is 0),
but the field dateOfInspection remains unchanged.  I've verified that the
values assigned to parameters (held in mRow) are correct and that the
connection string is correct and the connection is open.

I've also tried Cor's suggestion of using "?" parameters, and referring to
them by number.  Outcome is identical.

What can I possibly be doing wrong here?

Dim cmd As New OleDbCommand("update cert set dateofinspection=@dof where
id=@id", cnnData)
With cmd
 .CommandText = "update cert set dateofinspection=@dof where id=@id"
 .Parameters.Add("@id", OleDbType.BigInt)
 .Parameters.Add("@dof", OleDbType.Date)
 .Parameters("@id").Value = mRow.Item("id")
 .Parameters("@dof").Value = mRow("dateofinspection")
 .ExecuteNonQuery()
End With
JeremyGrand - 16 May 2005 22:49 GMT
ok, ok, I finally got it. Parameters are positionally sensitive.  I can't
believe I spent all this time not finding the answer to this.  Surely
hundreds of folks have had this problem!

> This is reposted from the vb forum since a couple of folks there thought
> it was more suited to this forum.
[quoted text clipped - 19 lines]
>  .ExecuteNonQuery()
> End With
Norman Yuan - 17 May 2005 01:19 GMT
Just a reminder: "Parameters are positionally sensitive" is only applied to
OleDbClient namespace. If you work with SQL Server, using SqlClient, your
code will be working OK. That is why many .NET samples dealing with Access
DB uses "?" in SQL statement instead of "@ParameterName". Since
@ParameterName is not used by OleDbClient, use it in code could lead to
hard-to-debug mistake, as you just experienced.

> ok, ok, I finally got it. Parameters are positionally sensitive.  I can't
> believe I spent all this time not finding the answer to this.  Surely
[quoted text clipped - 23 lines]
> >  .ExecuteNonQuery()
> > End With
Joe Fallon - 17 May 2005 02:19 GMT
Named parameters do not work with Access and .Net code.
The order they are created is the key.
In other words they are positionally sensitive. <g>

I have run into the same issue. As have many others.
Signature

Joe Fallon
Access MVP

> ok, ok, I finally got it. Parameters are positionally sensitive.  I can't
> believe I spent all this time not finding the answer to this.  Surely
[quoted text clipped - 23 lines]
>>  .ExecuteNonQuery()
>> End With

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.