Results 1 to 2 of 2

Thread: Functions and Subs...

  1. #1
    Join Date
    Feb 2003
    Sault Ste Marie, On, Canada

    Functions and Subs...

    HI, I'm using this code try and call my function when the user clicks the submit button but it's not working...any help? I'm also very new to WebMatrix how it works.


    Also what is the difference between a Sub and a Function? Also how does using the system Datasets make a difference when using either the Sub or Function to pull Data from the Database? Thx in Advance.
    <script runat="server">

    Function Find_Deceased(ByVal page_First_Name As String) As System.Data.DataSet
    Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Profiles\Dat"& _
    Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

    Page_First_Name = request.Form("Page_First_Name")

    Dim queryString As String = "SELECT [Profiles].[First_Name], [Profiles].[Last_Name], [Profiles].[Birth_Date], "& _
    "[Profiles].[About_Deceased], [Profiles].[Birth_Place] FROM [Profiles] WHERE ([Pr"& _
    "ofiles].[First_Name] = @Page_First_Name)"
    Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
    dbCommand.CommandText = queryString
    dbCommand.Connection = dbConnection

    Dim dbParam_page_First_Name As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
    dbParam_page_First_Name.ParameterName = "Page_First_Name"
    dbParam_page_First_Name.Value = page_First_Name
    dbParam_page_First_Name.DbType = System.Data.DbType.String

    Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
    dataAdapter.SelectCommand = dbCommand
    Dim dataSet As System.Data.DataSet = New System.Data.DataSet

    Return dataSet
    End Function

    <form runat="server">
    What is their First Name<asp:TextBox id="Page_First_Name" runat="server"></asp:TextBox>
    First Name<asp:TextBox id="First_Name" runat="server" value="<%=First_Name%>"></asp:TextBox>
    Last Name
    <asp:TextBox id="Last_Name" runat="server"></asp:TextBox>
    Place of Birth<asp:TextBox id="Birth_Place" runat="server"></asp:TextBox>
    Birth Date<asp:TextBox id="Birth_Date" runat="server"></asp:TextBox>
    Deceased<asp:TextBox id="Deceased" runat="server"></asp:TextBox>
    What was the person like?
    <textarea id="About_Deceased" style="WIDTH: 466px; HEIGHT: 278px" name="About_Deceased" rows="13" cols="48"></textarea>

    Picture<asp:TextBox id="Picture" runat="server"></asp:TextBox>
    <asp:Button id="Button1" runat="server" Text="Submit" onServerClick="Find_Deceased"></asp:Button>

  2. #2
    Join Date
    Nov 2002
    Auburn, AL
    a sub is a type of function really. It is just used to denote an event relateing to an object. I mean, like you have a sub for a button when it is clicked. It relates to event oriented programming. But a sub and a function act about the same, you can call them the same way, there is reall no major difference that I have ever seen.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center