Update problem with MS Access database

I am using Formview for inserting and updating database.  I can insert data but I couldn't update.  Can somebody help?

<asp:FormView ID="FormView1" runat="server" DataSourceID="myDs"  DefaultMode="Edit" DataKeyNames="EventID">

<EditItemTemplate>

 <asp:labeL runat="server" ID="l1" CssClass="calLabel" Width="100px">Title:</asp:labeL>

<asp:TextBox ID="Event" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>

<br />

<asp:Label ID="LabeL1" runat="server" CssClass="calLabel" Width="100px">Detail:</asp:Label>

<asp:TextBox ID="EventDetail" runat="server" TextMode="MultiLine" Text='<%# Bind("Detail") %>'></asp:TextBox>

<asp:Button ID="btnSubmit" runat="server" Text="Save" CommandName="Update"/>

<asp:Button ID="Button1" runat="server" CommandName="Cancel" Text="Cancel" />

</EditItemTemplate>

 

</asp:FormView>

<asp:AccessDatasource ID="myDs" runat="server"

DataFile="~/App_data/myDatabase.mdb"

SelectCommand="SELECT EventID,Title,Detail WHERE EventID = @EventID"

InsertCommand="INSERT INTO tbl_team_calendar (Title,Detail) VALUES (@Title,@Detail)"

UpdateCommand="Update tbl_team_Calendar Set Title=@Title, Detail=@Detail Where EventID=@EventID">

<SelectParameters>

<asp:QueryStringParameter Name="EventID" QueryStringField="EventID" Type="Int32" />

 

</SelectParameters>

</asp:AccessDatasource>

 

When I called myDS_Updated(...) event, the e.AffectedRows is 0.  I didn't update the record.  If I removed the where clause out of update command, the database is updating OK. (updated all record) but which where clause it didn't update anything.  Can someone help and tell me why?  Thank in advance.

0
vadmaster
7/2/2007 3:03:07 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
609 Views

Similar Articles

[PageSpeed] 5

 In AceessDataSource, the ? is used for placeholder to hold the parameter. The order of parameters is important in the parameter collection. Could you try the following to see whether the update works?

 <asp:AccessDatasource ID="myDs" runat="server" DataFile="~/App_data/myDatabase.mdb"

SelectCommand="SELECT EventID,Title,Detail WHERE EventID = ?"

InsertCommand="INSERT INTO tbl_team_calendar (Title,Detail) VALUES ?,?)"

UpdateCommand="Update tbl_team_Calendar Set Title=?, Detail=? Where EventID=?">

<SelectParameters>

<asp:QueryStringParameter Name="EventID" QueryStringField="EventID" Type="Int32" />

</SelectParameters>

<UpdateParameters>

<asp:Parameter Name="Title" Type="String" />

<asp:Parameter Name="Detail" Type="String" />

<asp:Parameter Name="EventID" Type="Int32" />

</UpdateParameters>

</asp:AccessDatasource>


Limno

0
limno
7/2/2007 3:18:39 PM

Yes!  That's work like a charm.  Thank you so much.

Now, I have more question if you can help.  In the same table, I have a field that is a list of userID, etc. (1,2,3,4)

In the edit template, I have checkboxlist that bind to user table.  What is the best way to grab the checkboxlist value and update it to userID field?

Here is the portion of my code in addition to previous code:

<asp:FormView ID="FormView1" runat="server" DataSourceID="myDs" DefaultMode="Edit"

DataKeyNames="EventID">

<EditItemTemplate>

<asp:Label ID="LabeL4" runat="server" CssClass="calLabel" Width="100px">Team Members:</asp:Label>&nbsp;

<asp:CheckBoxList id="userList" runat="server"  DataSourceID="userDS"

DataTextField="LastName" DataValueField="UserID" RepeatDirection="Horizontal" RepeatColumns="3"></asp:CheckBoxList>

....

</EditItemTemplate>

 

</asp:FormView>

<asp:AccessDatasource ID="userDs" runat="server" DataFile="~/App_data/myDB.mdb" DataSourceMode="DataReader"

Selectcommand="Select UserID, lastname  from tbl_Team">

0
vadmaster
7/2/2007 3:41:05 PM
Reply:

Similar Artilces:

Linking Web Form + MS ACCESS Database
I don't know if this is possible, but does anyone know if it's possible to create a web form linked a long with a Microsoft Access database. Say I'm filling out an online application, and if I submit that form, the MS Office database automatically updates itself with my information, so I can just download the database off the server later and read it from MS Acess rather than the web. Is this possible? Yes, it's certainly possible, and not too difficult. Check out this link:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office12062001.aspHope it helps.My Bl...

Problem reading excel file in .net to update an access database..
here is the scoop.. have a form that user uploads an excel file (very basic data.. 9 columns, multiple rows)after uploaded.. I want to read that data into an access databaseEasy enough, and its working.. however .NET doesn't seem to know when to quit reading the excel file and it always blows up. Here is my sample code. How can I tell .NET or Excel when to quit reading ?Dim myConnectionString As String Dim myConnection As Data.OleDb.OleDbConnection Dim myCommand As Data.OleDb.OleDbCommand Dim myDataReader As Data.OleDb.OleDbDataReader ' Set our connection string. Data file is "...

Problem Regarding MS Access database connection in c#.net
hi friend ..i m new in this field.i m creating some basic database application in asp.net mobile for web application.but i m facing problem to set the database path dynamically .Means i dont want write whole path of my datbase file in data source.Suppose i change my path then i m changing whole path every time this is very hectic problem.So plz anyone suggest me how to set my database file dynamically .I m attached my connection of database code.Thanks And Regards.Pash Inda  protected void Page_Load(object sender, EventArgs e) { //All controls on this page visible to ...

Accessing the PC database using a web-page and PowerBuilder 5.0 front-end and MS Access Database
I am trying to connect my web page, which is the standard HTML Explorier applet to my MS Access Database by way of PowerBuilder 5.0. I would like the steps and PowerBuilder Script to make this work. I was told that this is possible, but I don't know where to start, where to place the needed Script, and how to get the link on the web page to call up Powerbuilder to access the MS Access database. Help! You create a PB user object that has methods that do the access. You deploy that as a distributed PB component and then access it using Web.PB. Read more on distributed PB and...

Permission problem with access database using vb.net web service
Hi all,I wrote a simple web service that has two public methods. It uses Access database. As long as the codes are accessing the database read only, it is fine. The methods can query data without having any problem. But when it comes to writing some data to database, I get "use an updatable query" error, which means the database is read only. But it is not read only because aspx pages can write data to it without having any problem. The folder and file permissions for database file is correct. When i googled the issue i found out that web services acce...

MS access to MS access problem
I always used MS Access Database In my programs, now I want to use SQL SERVER database and so I started to design one. but it’s a little bit confusing ,I don’t know what can I use in change of these access Data type : MS access // MS access -------------- -------------------- Memo >>>>>>>> ?? AutoNumber >>>>> ?? * and if you think there is some difference between Ms access and SQL in D...

How to automatic update web form when there is an update action from database?
    Who could show me!I have a web fom that present a table from database, then someone update a record in that table from database throught another web form, I would like to the firts web form auto refresh to synchronizing it's present with the database, so the user don't need to press F5 key (refreshing page)I really need your help!Thank you!thinhhangdieu@yahoo.com...

Can ADO.Net query/update a MS Access database that contains table and fields that contain blank spaces and characters such as "#" in their names?????
I've recently been assigned an asp.net/MS Access project. My code works fine; however, there are table and fields in the Access database that contain blank spaces and characters such as "#" in their names. For example there is a table named "Purchase Orders" and in this table there are a few column fields with names such as "PO#" and “Customer PO#". My question: Is there some sort of wrapping method that I need to implement to allow my ADO.net objects (particularly the "OleDbDataAdapter" and the "DataRow") to accept these naming...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Retrieving image from 1 form to another form. (VB.Net & MS Access)
Hello!I'm getting the image in 1st form from database. When I'm moving to 2nd form how can i get the same image in form load?Thanks & RegardsPrasanna T Hi, Based on my understanding, you can display an image which is stored in the database on the form, and you want to display this image on another page.  If I have misunderstood you, please feel free to let me know. If we want to display the same image that is stored in the database, we can save the image into the folder and then refer to this image path using Image control on another page. I hope this helps. Thomas...

Updating Access database problems
I've got an application that will allow users to fill out a customer complaint form using data from an Access database, this all works fine until I upload it onto a local web server.  When running a copy on local host I can access the database on the web server to make any changes I want, but as soon as the program is run off of the web host it just silently loses all of my data. The only suggestions to fix this I've been able to find for this (really only one) dealt with the original tag but that's the problem I'm running into here. If anyone has any suggestions as to what the cause ...

Problems with Updating Access Database
Hi, i'm having problems updating Access Database using ASP.Net. I'm able to retrieve the data, modify the dataset and even display it; but when it comes to the last line in the code - 'Adapter.Update(ClassyDS, "Ads")' - i get the following error message: ---------------------- The Microsoft Jet database engine cannot find the input table or query 'Customer'. Make sure it exists and that its name is spelled correctly. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the e...

Accessing two web forms in a single web form
  Hi. I am developing a website in VS 2005 with Ajax & SQL Server. I am having 5 forms in my application. 1) Login Form 2) Main form 3) Form "A" 4) Form "B" I need to show the main form after the User login. I need to show all the contents of form A or form B (Ex: Form "A" user or form "B" user) in the Main Page. Can I show a single page having Main Form controls as well as Form "A" and Form "B" controls? I should access all the controls including Form A/B in the Main Page. Thanks ...

MS-Access Update Problem
I'm getting the follwoing error "Value of type 'Integer' can be converted to 'System.Data.OleBD.OLEDB'; how can I correct this?thanks;'calculate and load site compliance percentagespagePercentage = pagePass / pageSummySQL = "UPDATE oa SET percentage = " & pagePercentage & " WHERE oa = '" & myArray(i) & "'"objCmd = New OleDbCommand(mySQL, objConn)objConn.Open()objDR = objCmd.ExecuteNonQuery()objConn.Close() What is the datatype of the column "oa"? If its numeric you dont need the quotes around it.Al...

Web resources about - Update problem with MS Access database - asp.net.web-forms

Database - Wikipedia, the free encyclopedia
... requiring information. For example, modelling the availability of rooms in hotels in a way that supports finding a hotel with vacancies. Database ...

Database - Wikipedia, the free encyclopedia
A database is an organized collection of data . The data are typically organized to model aspects of reality in a way that supports processes ...

Five million customers affected by Vtech database hack
Toy and educational material seller Vtech has revealed five million customers were affected by a hack of its app database and has also suspended ...

Donald Trump wants "surveillance of certain mosques," database of refugees - Videos - CBS News
... rally in Birmingham, Alabama, Republican presidential candidate Donald Trump called for increased scrutiny over mosques, along with a database ...

IDG Contributor Network: Avoiding ginormous transaction logs with SharePoint databases
... why do we see these humongous transaction logs so often? I am going to blame it on a “misunderstanding” of how Microsoft describes a full database ...

Trump Wants A Database For All Syrian Refugees Who Enter America
Trump Wants A Database For All Syrian Refugees Who Enter America

Change your passwords: NexusMods suffers database breach
... security breach by posts on reddit. Cybersecurity firm REN-ISAC had apparently contacted several university IT departments about a database ...

VTech Admits Lack of Database Security Opened Door to Hack
A SQL injection, a common software flaw, was found to be the root cause in the VTech breach.

MapR And Big Data In The World's Largest Biometric Database Project
India?s Aadhaar project is one of the world?s most ambitious big data projects, aiming to collect, store, and utilize biometric information from ...

Trump calls for surveillance of some mosques, attempts to clarify remarks on Syrian database
Trump calls for surveillance of some mosques, attempts to clarify remarks on Syrian database

Resources last updated: 12/12/2015 1:50:49 PM