Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
rob merritt #1
trying to update a table after making a join select query on two tables
here is my problem distilled down I need to be able to change the
title of a book associated with an author there are 2 tables "author"
and "books"
books is keyed to author author.au_id -> books.author_key
so I select with
SelectCommand="select * from [authors],[books] where au_id =
author_key"
then try to update with
UpdateCommand="UPDATE [books] SET [book_title] = ? WHERE [author_key]
= ?"
this doesn't can I do this? I tried
UpdateCommand="UPDATE [books] SET [book_title] = ? WHERE [author_key]
= @au_id"
didn't help
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
void DetailsView1_ItemUpdated(Object sender,
DetailsViewUpdatedEventArgs e)
{
GridView1.DataBind();
}
void DetailsView1_ItemInserted(Object sender,
DetailsViewInsertedEventArgs e)
{
GridView1.DataBind();
}
void DetailsView1_ItemDeleted(Object sender,
DetailsViewDeletedEventArgs e)
{
GridView1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Editing Access Database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AccessDataSource ID="AccessDataSource1" Runat="server"
DataFile="data\pubs.mdb"
SelectCommand="select * from [authors],[books] where au_id
= author_key" >
</asp:AccessDataSource>
<asp:GridView ID="GridView1" Runat="server" AllowPaging="True"
AllowSorting="True" DataSourceID="AccessDataSource1"
DataKeyNames="au_id" AutoGenerateSelectButton="True">
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource2" Runat="server"
DataFile="data\pubs.mdb"
SelectCommand="select * from [authors],[books] where au_id
= author_key"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = ?"
UpdateCommand="UPDATE [books] SET [book_title] = ? WHERE
[author_key] = ?"
InsertCommand="INSERT INTO [authors] ([au_id], [au_lname],
[au_fname], [phone], [address], [city], [state], [zip], [contract],
[author_key], [book_title]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
FilterExpression="au_id='@au_id'">
<FilterParameters>
<asp:ControlParameter Name="au_id"
ControlID="GridView1"
PropertyName="SelectedValue"></asp:ControlParameter>
</FilterParameters>
</asp:AccessDataSource>
<asp:DetailsView ID="DetailsView1" Runat="server"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
DataSourceID="AccessDataSource2" DataKeyNames="au_id"
AutoGenerateInsertButton="True"
onitemupdated="DetailsView1_ItemUpdated"
oniteminserted="DetailsView1_ItemInserted"
onitemdeleted="DetailsView1_ItemDeleted">
</asp:DetailsView>
</div>
</form>
</body>
</html>
rob merritt Guest
-
Select, Join & field values - 2 tables
I had originally posted this in alt.comp.databases.mysql with no replies (I thought I had posted it here, my bad). Hopefully one of you bright... -
update and insert query error, but select works ok.
:rose; Any ideas spring to mind about the following issue? I'm getting an error trying to run an Update or Insert query. I can run a Select... -
How many dataBase tables can a dataSet table update via dataGrid?
I would like to display data in a datagrid in which the source of the data is multiple database tables. The select statement in the command object... -
SELECT from multiple tables (not join though)
Hi all, I have another question, I hope it isn't too basic. ^.^ I want to do a select from multiple tables but not join them. What I am trying... -
Use a SELECT @@IDENTITY as a sub-query in an UPDATE ?
It didn't work. UPDATE tblBlogs SET link_ID = blog_ID WHERE blog_ID = @@IDENTITY I get this error when trying to save an Access query: ...



Reply With Quote

