473,378 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ASP.NET Need Help With WEB MATRIX Insert

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(connectionStri ng)

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
Nov 20 '05 #1
2 2376
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(connectionStri ng)

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: po***********@yahoo.com (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: <7d**************************@posting.google.com >
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: gr**********@google.com
NNTP-Posting-Date: Thu, 9 Oct 2003 15:25:54 +0000 (UTC)
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnew s1.google.com!no
t-for-mailXref: 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(connectionStr ing)

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


Nov 20 '05 #2
Yay!

It works. And the link was helpful too!

Matt
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael Schoen | last post by:
Hi there, i=B4m actually developing a performance criticial system where I need to index a huge amount of protocoll data. These data are already in a chronological order, so if I push the data...
2
by: Peter Proost | last post by:
Hi group, I got the following piece of code which draws a square with stars round it, now I want the stars to rotate round the square, I can do this with the mx.rotate and a timer and an...
3
by: brianbasquille | last post by:
Hello all, Strange little problem here... am just trying to insert some basic information into an Access Database using OleDB. I'm getting a "Syntax error in Insert Into statement" when it...
2
by: Ted | last post by:
I have BULK INSERT T-SQL statements that work for all of my basic data tables except for one. Here is the problem statement (with obvious replacement of irrelevant path info): BULK INSERT...
3
by: kiask2343 | last post by:
Ok I need a little help here. I need the code to insert todays date into a specific field. This is what I think I need but I don't know how to make it work. INSERT INTO target ])] VALUES...
2
by: kaygee | last post by:
I need help with writing a for loop that will fill the 1st colunm of a (7by7) matrix with 1s
5
by: pwalker | last post by:
Hi everyone, I am trying to get my head around iterators used on vectors. Let's take the code below: ------------- std::vector<intv1; std::vector<intv2; v1.push_back( 1 );
4
by: ryushinyama | last post by:
I had to do a lot of searching to get this one to work and in doing so I saw a lot of different sites where people were looking for this answer so I thought I would put it up. If you are trying...
3
by: bob laughland | last post by:
Hi All, I am using a combination of LINQ to SQL and bulk insert. In the process of performing 'one unit of work' I will be doing things like reading, and deleting records using LINQ to SQL and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.