asp.net - What development environment setup steps am I missing? -


i'm working on database project school's science fair. need insert data .aspx webform access database. i've been using "microsoft visual web developer" write following .aspx.vb code. when press "submit" button doesn't send data database should. development environment setup steps missing?

i've been following tutorial (http://www.youtube.com/watch?v=szm3bfsovw0). here's aspx source:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <%@ page language="c#" %>  <script runat="server">      protected void button1_click(object sender, eventargs e)     {      } </script> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">  <head id="head1" runat="server"></head> <meta content="en-us" http-equiv="content-language" /> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <title>science fair registration</title>  <form id="form1" runat="server" class="auto-style1">     <br />      <%-- graphics--%>      <center><h1>science fair registration</h1></center>     <asp:multiview id="multiview1" runat="server" activeviewindex="0">         <asp:view id="view1" runat="server">              <br />             first name:<br />             <asp:textbox id="textboxsfirst" runat="server" width="500px"></asp:textbox>             <br />             last name:<br />             <asp:textbox id="textboxslast" runat="server" width="500px"></asp:textbox>             <br />             student email address:<br />             <asp:textbox id="textboxsemail" runat="server" width="500px"></asp:textbox>             <br />             <br />             <br />             school:<br />             <asp:textbox id="textboxschool" runat="server" width="500px"></asp:textbox>             <br />             grade:<br />             <asp:dropdownlist id="dropdownlistgrade" runat="server" width="86px">                 <asp:listitem>7</asp:listitem>                 <asp:listitem>8</asp:listitem>                 <asp:listitem>9</asp:listitem>                 <asp:listitem>10</asp:listitem>                 <asp:listitem>11</asp:listitem>                 <asp:listitem>12</asp:listitem>             </asp:dropdownlist>             <br />             teacher's last name (only):<br />             <asp:textbox id="textboxtlastname" runat="server" width="500px"></asp:textbox>             <br />             teacher e-mail:<br />&nbsp;<asp:textbox id="textboxtemail" runat="server"                  width="500px"></asp:textbox>             <br />              <%-- teacher phone number:<br />&nbsp;<asp:textbox id="tphone" runat="server" width="500px"></asp:textbox> --%>             <%-- might put above in later --%>             <br />             <br />catagory :<br />&nbsp;<asp:dropdownlist id="dropdownlistcatagory" runat="server" width="212px">                 <asp:listitem>behavorial &amp; social sciences</asp:listitem>                 <asp:listitem>biochemistry &amp; microbiology</asp:listitem>                 <asp:listitem>botany</asp:listitem>                 <asp:listitem>environmental sciences</asp:listitem>                 <asp:listitem>medicine &amp; health</asp:listitem>                 <asp:listitem>zoology</asp:listitem>                 <asp:listitem>chemistry</asp:listitem>                 <asp:listitem>computer science</asp:listitem>                 <asp:listitem>earth &amp; space sciences</asp:listitem>                 <asp:listitem>engineering</asp:listitem>                 <asp:listitem>mathematics</asp:listitem>                 <asp:listitem>physics</asp:listitem>             </asp:dropdownlist>             <br />             exibit title :<br />&nbsp;<asp:textbox id="textboxtitle" runat="server" width="500px"></asp:textbox>             <br />             exhibit use electricity?<br />             <%-- possible issues here, may need use 1 & 0 instead--%>             <asp:dropdownlist id="dropdownlistelectricity" runat="server">                 <asp:listitem value="true">yes</asp:listitem>                 <asp:listitem value="false">no</asp:listitem>             </asp:dropdownlist>             <br />             <br />             <br />             <asp:button id="button1" runat="server" text="submit" onclick="button1_click"                  style="height: 26px" />             <br />          </asp:view>     </asp:multiview> </form>  </body>  </html> 

here aspx.vb source:

imports system imports system.data imports system.data.oledb  partial class _default1     inherits system.web.ui.page      protected sub button1_click(byval sender object, byval e system.eventargs) handles button1.click         'form data requests---------------------------------------------------------------------------------------------------------         dim strname string = request.form("first") 'in paraenthesis may item name in form         dim strlast string = request.form("last")         dim strstudentemail string = request.form("studentemail")          dim strschool string = request.form("school")         dim numgrade integer = request.form("grade") '*dropdown list         dim strteacher string = request.form("teacher") 'teacher's last name         dim strteacheremail string = request.form("teacheremail")          dim strcatagory string = request.form("catagory") '*dropdown list         dim strtitle string = request.form("title")         dim boolelectricity boolean = request.form("electricity") '*possible boolean electricity           'open db connection---------------------------------------------------------------------------------------------------------         dim strsql string         dim dbconn oledbconnection = nothing          dbconn = new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("sf13.mdb"))         dbconn.open();           'sql actions ----------------------------------------------------------------------------------------------------------         strsql = "insert exhibits (first, last, school, teacher, title, grade, category, teachernumber, studentemail, electricity, teacheremail) values (?,?,?,?,?,?,?,?,?,?,?)"         objcmd = new oledbcommand(strsql, dbconn) 'oledbcommand should highlighted - missing imports....          objcmd.parameters.add(new system.data.oledb.oledbparameter("@first", strname))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@last", strlast))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@school", strschool))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@teacher", strteacher))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@title", strtitle))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@grade", numgrade))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@category", strcatagory))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@studentemail", strstudentemail))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@electricity", boolelectricity))         objcmd.parameters.add(new system.data.oledb.oledbparameter("@teacheremail", strteacheremail))         objcmd.executenonquery()          'close db connection         dbconn.close()         response.write("thank registering")      end sub  end class 

fixed changed language vb , added "code behind tag".

<%@ page title="" language="vb" masterpagefile="~/site.master" autoeventwireup="false" codefile="sciencefair.aspx.vb" inherits="_default" %> 

it looks you're mixing in-line coding style code-behind. try changing page language vb , specifying code-behind class:

<%@ page language="vb" inherits="_default1" %> 

also, remove script block @ start of file.

further reading


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -