?
Solved

form to database asp.net web application with VB

Posted on 2011-03-03
6
Medium Priority
?
968 Views
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

THANKS!
Stiggley
0
Comment
Question by:Stiggley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35028918
Hi,

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


0
 

Author Comment

by:Stiggley
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">
        .style1
        {
            text-indent: -.25in;
            font-size: 11.0pt;
            font-family: Calibri, sans-serif;
            margin-left: .5in;
            margin-right: 0in;
            margin-top: 0in;
            margin-bottom: .0001pt;
        }
    </style>
</head>
<body>
<center>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
<p>
 <img alt="top" src="top.jpg" style="height: 255px; width: 520px" /> </br> Please
        Answer the Following Questions and click "Submit":

</p>
   
   
    <p>
     
        Please Enter Your Email Address:  </br>
        <asp:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox> </br>
       
   
   
    </p>
    <p>
          Please Confirm Your Email Address: </br>
        <asp:TextBox ID="TextBox2" runat="server" Width="200px"></asp:TextBox> </br>
       
         
    </p>
   
 
    <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" />
 
</asp:radiobuttonlist>
    </p>
 
    <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:radiobuttonlist>
        </span></p>
   
   
 
<p>
    <asp:Button ID="Button1" runat="server" Text="Submit"    />
    </p>
   
   
   
   
 
    </form>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
    </center>
</body>
</html>

__________________________________________________________________________---

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
0
 
LVL 13

Expert Comment

by:gamarrojgq
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)

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
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
0
 
LVL 13

Expert Comment

by:gamarrojgq
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

http://www.asp.net/general/videos/intro-to-web-forms

http://www.asp.net/general/videos/page-lifecycle-events

http://www.asp.net/general/videos/intro-to-aspnet-controls

http://www.asp.net/general/videos/submit-and-postback

0
 

Author Closing Comment

by:Stiggley
ID: 35067810
Thank you very much
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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