form to database web application with VB

Posted on 2011-03-03
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 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  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 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, 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" "">

<html xmlns="" >
<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 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)

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.


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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now