form to database asp.net web application with VB

Posted on 2011-03-03
Medium Priority
Last Modified: 2012-05-11
Hi Everyone,

     I have written several vb applications that interface with our advantagedatabase, but I am currently working on MY FIRST asp.net web application.  I need the user to answer a few questions and click my submit button.  Once the button is clicked I need to send the information on the form into a table on my database.  I would rather not use access.  I have an older sybase database and I know how to talk with it fine in a standard vb app.  I guess im just not sure how vb works with asp.net.  I have created the page already.  If i go to my design view I can add controls.  If i double click on the controls it takes me to the vb code.  However if i write code for those controls, it does nothing on my web app when I run it.  If i go to my asp.net source code it also has the controls coded.  I would like the submit button to be able to start my vb app which would pull all the info into my vb function and submit it to my database.

Any direction would be greatly appreciated

Question by:Stiggley
  • 3
  • 3
LVL 13

Expert Comment

ID: 35028918

What kind of code you wrote for the controls? are you bound your controls to a DataSoucre? or you are setting the values of the controls programatically?

Can you post an example?

Here is a link where you can see an example

http://www.beansoftware.com/ASP.NET-Tutorials/Connecting-Access-SQL-Server.aspx, it uses acces and SQL server but the it could give you an idea


Author Comment

ID: 35028994
Hi and thank you....

I have not actually started connecting to the database because I am confused on just basic funtionality between asp and vb.  for example... I tried entering code where if you click submit one of the text boxes text changes.  It does not work.. or If i changed the selection of a radio button through the code it would not work.. below is the template for both the asp and the vb.

Here is my asp code  and below under the line is my vb code.... I f i try to type any code for my submit button on the vb code it will not execute in the web app

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

<!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>Dynamic Email "opt-out" Survey</title>
    <style type="text/css">
            text-indent: -.25in;
            font-size: 11.0pt;
            font-family: Calibri, sans-serif;
            margin-left: .5in;
            margin-right: 0in;
            margin-top: 0in;
            margin-bottom: .0001pt;
    <form id="form1" runat="server">
 <img alt="top" src="top.jpg" style="height: 255px; width: 520px" /> </br> Please
        Answer the Following Questions and click "Submit":

        Please Enter Your Email Address:  </br>
        <asp:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox> </br>
          Please Confirm Your Email Address: </br>
        <asp:TextBox ID="TextBox2" runat="server" Width="200px"></asp:TextBox> </br>
    <p class="style1" style="mso-list: l0 level1 lfo1">
        <![if !supportLists]><span style="mso-fareast-font-family:Calibri;color:black">
        <span style="mso-list:Ignore">
        <span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </span></span></span><![endif]><span style="color:black">Are you still suffering
        from back pain, neck pain, or migraine headaches?&nbsp; </span>
        <asp:radiobuttonlist id="radio1" runat="server">
  <asp:listitem id="option1" runat="server" value="Yes" />
  <asp:listitem id="option2" runat="server" value="No" />
    <p class="style1" style="mso-list: l0 level1 lfo1">
        <span style="color:black">Would you recommend us to a friend
        with back or neck pain?
        <asp:radiobuttonlist id="radio" runat="server">
  <asp:listitem id="Option3" runat="server" value="Yes" />
  <asp:listitem id="Option4" runat="server" value="No" />
    <asp:Button ID="Button1" runat="server" Text="Submit"    />


now the vb code:

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

    End Sub
End Class
LVL 13

Expert Comment

ID: 35029107
Ok, in the vb code you do not have any code jet, so if you want to change the text property of the textboxes on the submit button you code for that button shoul be

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        TextBox1.Text = "Text Added in Codebehind"
        TextBo12.Text = "This one too"
    End Sub

If this is your first asp.net application perhaps there are somethings you need to know: (if you know it already, please forgiveme)

1.- The vb.code executes on the Server not in the client
2.- Each time you click on a button the page make a post and returns to the Server to executes the code for that button
3.- Every time the page return to the server runs the PAGE LOAD event, so if you have code there that asign values to the Textboxes this will discard the changes made by the user, so you have to check if its the first time the page is rendered or if is a Post event called by the user (cliking a button for example)

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Accepted Solution

Stiggley earned 0 total points
ID: 35029689
OHHHH!  I think I get it... So basically.... The user will not see the text box text change.... but it does change it on the server?  so my code looks ok i just need to program the vb part like I normally do?

thanks again
LVL 13

Expert Comment

ID: 35029782
Well the User will see the changes AFTER the pages executes all the code, so, let say the user enter his email in TextBox1, when click Submit button, the email entered by the users goes to the server and in the PAGE LOAD event you can see that value, if there is no code in the PAGE LOAD event that change the TextBox1 text property, it will execute the code in the BUTTON1_CLICK event, here you can still see the email entered by the user, if in this event you have this code

TextBox1.Text = "Text Added in Codebehind"

when the page reloads, the users will see "TEXT ADDED IN CODEBEHIND" instead of the email he entered before, but, if you do not have code that changes the TextBox1 text property, when the pages reloads the user will see the same email he entered

I recommend you to watch this videos






Author Closing Comment

ID: 35067810
Thank you very much

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question