Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Inserting Records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Inserting Records

 Post Reply Post Reply Page  12>
Author
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Topic: Inserting Records
    Posted: 11 November 2003 at 5:09pm

Guys,

This piece of code to insert a new student into the DB was working perfectly, i dont know hwat i did to screw it up but maybe the error is blatantly obvious to someone more experienced.

<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub btnInsertClick(Sender As Object, E As EventArgs)

         Dim aConnection As OleDbConnection = New OleDbConnection
         Dim aConnectionString As String
         Dim aQuery As String
         aConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\records.mdb"
         aConnection.ConnectionString = aConnectionString
         Dim aCommand As OleDbCommand = New OleDbCommand
         aConnection.Open()
         aQuery = "Insert Into Students(StudentID, FirstName, LastName, EmailName, BirthDate, Pword) VALUES ('"& StudID.Text &"', '"& F_Name.Text &"', '"& L_Name.Text &"', '"& Email.Text &"', '"& D_O_B.Text &"', '"& Pword1.Text &"')"
         aCommand.Connection = aConnection
         aCommand = New OleDbCommand(aQuery, aConnection)
        
    End Sub

</script>
<html>
<head>
</head>
<body background="./images/graduate.gif">
    <form runat="server">
        <div align="center">
             <table width="607" align="center" border="0">
                 <tbody>
                     <tr>
                           <td colspan="3" height="201">
                               <img height="91" src="images/crest.gif" width="574" align="top" border="3" />
                               <table cellspacing="0" cellpadding="0" width="100%" border="0">
                                   <tbody>
                                         <tr>
                                             <td height="80">
                                                  <h2 align="center"><font face="geneva,arial" size=+3><b>Registration Information </b></font>
                                                  </h2>
                                                  <font face="geneva,arial" size="-1">&nbsp; </font></td>
                                         </tr>
                                   </tbody>
                               </table>
                           </td>
                     </tr>
                     <tr>
                           <td align="right" width="198">
                               <font face="Arial" size="2">First Name: </font></td>
                           <td width="399">
                               <asp:TextBox id="F_Name" runat="server" width="200px" maxlength="25"></asp:TextBox>
                               <asp:RequiredFieldValidator id="FNameReq" runat="server" ErrorMessage="* You Must Enter a First name" ControlToValidate="F_Name"></asp:RequiredFieldValidato r>
                           </td>
                     </tr>
                     <tr>
                           <td align="right">
                               <font face="Arial" size="2">Last Name:</font>
                           </td&g

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:13pm

are we supposed to guess what "isn't working perfectly" is?

do you get an error message?

Contribute to the working anarchy we fondly call the Internet
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:15pm

also.. no where do you actually execute the command

aCommand.ExecuteNonQuery()

after the "New Command" line

Contribute to the working anarchy we fondly call the Internet
Back to Top
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:16pm
No error message, just when i click the submit button the password fileds clear and usually after i did that it was entered but now it doesnt enter it. Is it a problem with where i have my DB?? All my files are in the wwwroot folder and i have my DB there as well.
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:19pm
let me know how it turns out after you add the line you are missing
Contribute to the working anarchy we fondly call the Internet
Back to Top
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:23pm

System.Data.OleDb.OleDbException: Operation must use an updateable query.

this is the error i get when i put in that line, i took it out cos it was causing this error earlier, what exactly does the line do???

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2003 at 5:43pm

omg.. you cannot be serious?

a line causes an error and you just "take it out" to try to fix it?  lol.. you got some issues ahead if thats your method of solving problems.....

that line i post is what actually runs the query you are presenting the database... your code w/o it never says "do it"

and that "updatable query" error message (as i believe this is in borgs tutorials section) means that the database is in a directory which the web server doesn't have the proper permissions... which it sure in hell shouldn't since your database is sitting in the root of your web application (easily the WORST place for a database to exist)....

you gots some readin' to do... starting with here and that PM i sent you

Contribute to the working anarchy we fondly call the Internet
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 12 November 2003 at 8:24am

You could make the sub actually handle something. I don't see where you call the sub when the button is clicked, but that could be me, since I just ran quickly trough it.

EDIT: Alright! I've seen it. But using the Handles.Button might be better.

My solution is easy. Build it again! Sometimes I screw up to, and rebuilding the thing from scratch is the best solution.



Edited by Diep-Vriezer
Gone..
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.