P
Polyhedron_12
I am having problems calling functions in general in VB. I keep
getting alot of errors. Can anybody help me out with this? I put the
error message on the same line that it says it is at. I believe that I
am not calling the function correctly.
The MyInsertMethod function is the function that comes in the Web
Matrix Toolbox
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
Function MyInsertMethod(ByVal tier1Name As String) As Integer
Dim connectionString As String = "server='(local)'; user
id='sa'; password='ladiedah'; database='accessory'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "INSERT INTO [Tier1]
([tier1Name]) VALUES (@tier1Name)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_tier1Name As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_tier1Name.ParameterName = "@tier1Name"
dbParam_tier1Name.Value = tier1Name
dbParam_tier1Name.DbType =
System.Data.DbType.StringFixedLength
dbCommand.Parameters.Add(dbParam_tier1Name)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
Label1.Text = "Hello2"
End Function
Sub Page_Load
Label1.Text = "Hello"
End Sub
'
</script>
<html>
<head>
</head>
<body>
<form onsubmit="MyInsertMethod(TextBox1.Text)" runat="server">
<p>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" onclick="MyInsertMethod
TextBox1.Text" runat="server" Text="Add Tier"></asp:Button> 'BC30408:
Method 'Public Function MyInsertMethod(tier1Name As String) As
Integer' does not have the same signature as delegate 'Delegate Sub
EventHandler(sender As Object, e As System.EventArgs)
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
Thank You,
Matt Saragusa
getting alot of errors. Can anybody help me out with this? I put the
error message on the same line that it says it is at. I believe that I
am not calling the function correctly.
The MyInsertMethod function is the function that comes in the Web
Matrix Toolbox
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
Function MyInsertMethod(ByVal tier1Name As String) As Integer
Dim connectionString As String = "server='(local)'; user
id='sa'; password='ladiedah'; database='accessory'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "INSERT INTO [Tier1]
([tier1Name]) VALUES (@tier1Name)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_tier1Name As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_tier1Name.ParameterName = "@tier1Name"
dbParam_tier1Name.Value = tier1Name
dbParam_tier1Name.DbType =
System.Data.DbType.StringFixedLength
dbCommand.Parameters.Add(dbParam_tier1Name)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
Label1.Text = "Hello2"
End Function
Sub Page_Load
Label1.Text = "Hello"
End Sub
'
</script>
<html>
<head>
</head>
<body>
<form onsubmit="MyInsertMethod(TextBox1.Text)" runat="server">
<p>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" onclick="MyInsertMethod
TextBox1.Text" runat="server" Text="Add Tier"></asp:Button> 'BC30408:
Method 'Public Function MyInsertMethod(tier1Name As String) As
Integer' does not have the same signature as delegate 'Delegate Sub
EventHandler(sender As Object, e As System.EventArgs)
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
Thank You,
Matt Saragusa