Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2009, 09:25 PM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default Problem with inserting, deleting, and updating using the detalis view

Hey,

I've created a database using access. i connected it with asp.net using the wizard, did not type any code for it.
Then i draged the details views to the default page, and configured it to one of the table.

The problem is it gives me error while i insert delete or update. i dont see where the problem is comming from since i am using the GUI to configure all of this.

The code looks like this


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataKeyNames="Room Number"
DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Room Number" HeaderText="Room Number"
ReadOnly="True" SortExpression="Room Number" />
<asp:BoundField DataField="Model Number" HeaderText="Model Number"
SortExpression="Model Number" />
<asp:BoundField DataField="Serial NUmber" HeaderText="Serial NUmber"
SortExpression="Serial NUmber" />
<asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer"
SortExpression="Manufacturer" />
<asp:BoundField DataField="Fsu Tag" HeaderText="Fsu Tag"
SortExpression="Fsu Tag" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [Engineering Tech] WHERE [Room Number] = ?"
InsertCommand="INSERT INTO [Engineering Tech] ([Room Number], [Model Number], [Serial NUmber], [Manufacturer], [Fsu Tag]) VALUES (?, ?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Engineering Tech]"
UpdateCommand="UPDATE [Engineering Tech] SET [Model Number] = ?, [Serial NUmber] = ?, [Manufacturer] = ?, [Fsu Tag] = ? WHERE [Room Number] = ?">
<DeleteParameters>
<asp:Parameter Name="Room_Number" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Model_Number" Type="String" />
<asp:Parameter Name="Serial_NUmber" Type="Int32" />
<asp:Parameter Name="Manufacturer" Type="String" />
<asp:Parameter Name="Fsu_Tag" Type="String" />
<asp:Parameter Name="Room_Number" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Room_Number" Type="String" />
<asp:Parameter Name="Model_Number" Type="String" />
<asp:Parameter Name="Serial_NUmber" Type="Int32" />
<asp:Parameter Name="Manufacturer" Type="String" />
<asp:Parameter Name="Fsu_Tag" Type="String" />
</InsertParameters>
</asp:SqlDataSource>

</div>
</form>
</body>
</html>
 
Old November 30th, 2009, 09:28 PM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default bivek again

i could send you my zip file but i cant find a way to upload it over here?
 
Old December 1st, 2009, 06:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

As I indicated in my private e-mail message, you need to supply lots of details:

1. How does your database look? What tables and columns does it contain? Are they related to each other? Do you have identities and primary keys set for some columns?

2. What error do you get exactly and when?

3., How do your browse to the site? Using IIS? Using the built-in web server?

Without this information, this question is pretty difficult to answer......

I think you need to be member for a while before you can upload files. Let's try if we can fix it without a zip file; otherwise; you can send it to my e-mail address.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
bivek (December 1st, 2009)
 
Old December 1st, 2009, 11:19 AM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default more details regarding the problem

Hello,
Thank for the reply. The project deals with projector inventories and since every projector has a different serial number and i need to display projecotors based per room the tables do not have any relationship. right now i have only table for experimentinal purpose but still has the problem.

I made a table using access.

The column consists of

Serial No (its the primary key)
Room Number
Model Number
Make
FSU Tag Number

All i did was input some data on the column and connected it to asp.net, then i draged the details view, and configured the advance options so that it enables me to add delete and edit new data.

while i try to delete the data it does not delete but does not give any error messeage

while i try to update it does not update but does not give any error messeage

Whilt i try to add new record it gives the error "You must enter a value in the 'Engineering Tech.Room Number' field" but i have alredy inputed a value

I browse the site using IE and its the built in web server i use.

I have send you the copy of access and a zip file to your email address.

Again i would like to thank you for helping me out.
 
Old December 1st, 2009, 11:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you try downgrading your database to the previous Office format (.mdb) and see if that helps? You can use Save As in Access.....

Also, make sure that the App_Data folder has the correct permissions applied as explained in Chapter 18.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 1st, 2009, 12:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

One more thing: get rid of all the horrible column and table names by replacing the spaces. That is, rename the table Engineering Tech to EngineeringTech, the column
Room Number to RoomNumber.

Then deleted all the spaces in the references to these items in your code, and the underscores from the parameter references. That should fix the problem...

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 1st, 2009, 12:44 PM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default not working

I did what you suggested....removed the underscore from the paramater, remove the space....and i even tried to make the database in the older version but now it gives me new error...i can insert just fine but while i try to delete or edit it gives me "No value given for one or more required parameters"
Error
 
Old December 1st, 2009, 01:14 PM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default It works

I tried it again, and now it works. Thank you for your help.
 
Old December 1st, 2009, 01:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I looked at your code, and the Access 2007 format should work. I think just the spaces in the object names are to blame. You're so much better off not using characters other than A to Z and 0 to 9 in your table names. Spaces or other symbols will get you nothing but trouble...

Glad it's working now.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 1st, 2009, 06:07 PM
Registered User
 
Join Date: Nov 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default It works

Thank you for Helping me out...





Similar Threads
Thread Thread Starter Forum Replies Last Post
need help updating and deleting!!!!!!!!!!!!!!! samXR PHP Databases 1 July 15th, 2009 03:36 AM
need help updating and deleting!!!!!!!!!!!!!!! samXR Beginning PHP 1 May 29th, 2009 04:46 PM
need help updating and deleting!!!!!!!!!!!!!!! samXR SQL Language 2 May 22nd, 2009 02:50 AM
need help updating and deleting!!!!!!!!!!!!!!! samXR MySQL 0 May 21st, 2009 09:08 PM
updating and deleting record PinkyCat Classic ASP Databases 4 March 16th, 2005 05:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.