Last post Oct 30, 2007 09:49 PM by jpuckett
Oct 30, 2007 04:29 PM|richasr87|LINK
Hi I am very new to both ASP and SQL but I am having a problem which doesnt give off any signals as to what is actually wrong.
I am creating a simple webpage using an Access Database as the datasource along with a GridView and DetailsView in order to insert/delete/edit and show information from the database neatly on the page.
Unfortunately once setup, the form only adds information from 3 of the 5 fields into the database, leaving me with blanks in the first two columns, I have no idea why this is happening and I was hoping someone could help me;
This is my source code of the Commands the form is using.
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DeleteCommand="DELETE FROM [table] WHERE [No] = ? AND [Reg No] = ? AND [Forename] = ? AND [Surname] = ? AND [Course] = ? AND [Entry] = ?"
InsertCommand="INSERT INTO [table] ([Reg No], [Forename], [Surname], [Course], [Entry]) VALUES ([Reg No], [Forename], [Surname], [Course], [Entry])"
SelectCommand="SELECT * FROM [table]"
UpdateCommand="UPDATE [table] SET [Reg No] = ?, [Forename] = ?, [Surname] = ?, [Course] = ?, [Entry] = ? WHERE [No] = ? AND [Reg No] = ? AND [Forename] = ? AND [Surname] = ? AND [Course] = ? AND [Entry] = ?"
I am at a loss currently and would appreciate some help[:)]
Oct 30, 2007 06:24 PM|jpuckett|LINK
Im confused at to what is " the form only adds information from 3 of the 5 fields into the database " means.
Does this mean your SELECT works fine and you can display all 5 columns but the insert fails?
Oct 30, 2007 08:21 PM|richasr87|LINK
Apologies, the SELECT seems to work fine but the INSERT is what seems to be causing the problem, though there appears to be no fault with the statement;
That is what Web Developer has generated, I'm not coding this myself exactly as I'm learning as I go along so to speak.
Oct 30, 2007 09:31 PM|jpuckett|LINK
alrighty, do me a favor and post your entire aspx and your code behind so I can peek at it.
Oct 30, 2007 09:36 PM|richasr87|LINK
Ok this is my source code from the aspx page, this is all Web Developer has created for me.
Oct 30, 2007 09:49 PM|jpuckett|LINK
well, Access is not my forte, however, I don't believe you can call a column "no" because that is a reserved word. Perhaps you should rename your columns to something a bit more obfuscated so that you aren't using a reserved word.