PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

ASP.NET Need Help With WEB MATRIX Insert

 
 
Polyhedron_12
Guest
Posts: n/a
 
      9th Oct 2003
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
 
Reply With Quote
 
 
 
 
Sarika [MSFT]
Guest
Posts: n/a
 
      9th Oct 2003
Matt,
The following sample is a good source of
understanding functionality of event handling on the buttons in web form.

ms-help://MS.VSCC/MS.MSDNQTR.2003APR.1033/cpref/html/frlrfSystemWebUIWebCont
rolsButtonClassOnClickTopic.htm

Here is the modified code that get past the error you were experienceing.
Hope this helps.
Thanks,
Sarika

<%@ Page Language="VB" %>
<HTML>
<HEAD>
<script runat="server">

' Insert page code here
Sub SubmitBtn_Click(sender As Object, e As EventArgs)
Message.Text = "Hello World!!"
MyInsertMethod(TextBox1.Text)
End Sub 'SubmitBtn_Click


Function MyInsertMethod(ByVal tier1Name As String) As Integer
Dim connectionString As String = "server='(local)';
userid='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>
</HEAD>
<body>
<form onsubmit="MyInsertMethod(TextBox1.Text)" runat="server" ID="Form2">
<p>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" onclick="SubmitBtn_Click" 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>
<asp:label id="Message" runat="server"/>

<!-- Insert content here -->
</form>
</body>
</HTML>

--------------------
>From: (E-Mail Removed) (Polyhedron_12)
>Newsgroups: microsoft.public.dotnet.languages.vb
>Subject: ASP.NET Need Help With WEB MATRIX Insert
>Date: 9 Oct 2003 08:25:54 -0700
>Organization: http://groups.google.com
>Lines: 78
>Message-ID: <(E-Mail Removed)>
>NNTP-Posting-Host: 68.159.1.146
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1065713154 20676 127.0.0.1 (9 Oct 2003

15:25:54 GMT)
>X-Complaints-To: groups-(E-Mail Removed)
>NNTP-Posting-Date: Thu, 9 Oct 2003 15:25:54 +0000 (UTC)
>Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews1.google.com!no
t-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:145354
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>
>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
>


 
Reply With Quote
 
Polyhedron_12
Guest
Posts: n/a
 
      10th Oct 2003
Yay!

It works. And the link was helpful too!

Matt
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I transpose nXm matrix to mXn Matrix MIHir Microsoft Excel Worksheet Functions 2 9th Aug 2008 11:44 AM
custom Matrix class to VC++ standard doubles Matrix class Manjree Garg Microsoft VC .NET 5 21st Dec 2007 05:42 PM
Looking for matrix inside a matrix juli jul Microsoft C# .NET 1 15th Jan 2006 04:48 PM
Web Matrix guide tour: INSERT in Access table fails =?Utf-8?B?RWtoYWF0?= Microsoft ASP .NET 3 18th Nov 2004 04:39 AM
Support for Matrix, Matrix.Rotate or Grapics.RotateFlip for a Bitmap on Compact ? Mark Johnson Microsoft Dot NET Compact Framework 3 3rd Dec 2003 11:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 AM.