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.
onSeverclick="Find_Deceased">
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"& _
"abases\Profiles.mdb"
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
dbCommand.Parameters.Add(dbParam_page_First_Name)
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
What is their First Name<asp:TextBox id="Page_First_Name" runat="server"></asp:TextBox>
</p>
First Name<asp:TextBox id="First_Name" runat="server" value="<%=First_Name%>"></asp:TextBox>
<p>
Last Name
<asp:TextBox id="Last_Name" runat="server"></asp:TextBox>
</p>
<p>
Place of Birth<asp:TextBox id="Birth_Place" runat="server"></asp:TextBox>
</p>
<p>
Birth Date<asp:TextBox id="Birth_Date" runat="server"></asp:TextBox>
</p>
<p>
Deceased<asp:TextBox id="Deceased" runat="server"></asp:TextBox>
</p>
<p>
What was the person like?
</p>
<p>
</p>
<textarea id="About_Deceased" style="WIDTH: 466px; HEIGHT: 278px" name="About_Deceased" rows="13" cols="48"></textarea>
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.
Bookmarks