How do I call a procedure?

qwerty150

New Member
The code in question is below. If you look at the "if strBandName <> "" then Inse*****d()", you'll notice that I'm trying to call the Inse*****d sub. However, I get the following error:<BR><BR>No argument specified for non-optional parameter 'e' of 'Public Sub Inse*****d(s As Object, e As System.EventArgs)'.<BR><BR>What arguments am I supposed to be passing?<BR><BR>------------------<BR><BR><%@ Import Namespace="System.Data.SqlClient" %><BR><BR><Script runat="Server"><BR><BR>dim strBandName, strBandNick As String<BR><BR>Sub Page_Load( s As Object, e As EventArgs )<BR><BR> strBandName = "winger2"<BR> strBandNick = Request("bandnick")<BR><BR> if strBandName <> "" then Inse*****d()<BR>End Sub<BR><BR>Sub Inse*****d( s As Object, e As EventArgs )<BR> Dim conData As SqlConnection<BR> Dim cmdInsert As SqlCommand<BR> <BR> conData = http://aspmessageboard.com/archive/index.php/New SqlConnection( "SERVER=xxxxxxxxxxxxxxxxx" )<BR> cmdInsert = New SqlCommand( "Insert bands ( bandname,bandnick ) values ( @bandname, @bandnick )", conData )<BR> cmdInsert.Parameters.Add( "@bandname", strBandName)<BR> cmdInsert.Parameters.Add( "@bandnick", strBandNick)<BR> conData.Open()<BR> cmdInsert.ExecuteNonQuery<BR> conData.Close()<BR> Response.write("thanks man")<BR>End Sub<BR><BR></Script>You shouldn't have the default page level event parameters in your Sub declaration. Your Sub might look something like this:<BR><BR>Sub InsertBad()<BR>....Do Stuff....<BR>End Sub<BR><BR>You only need parameters if you intend to pass values that are required in the Sub. For example, you should probably be passing in the values for strBandName and strBandNick. You could do something like:<BR><BR>Sub Inse*****d(strBandName As String, strBandNick As String)<BR>....Do Stuff....<BR>End Sub<BR><BR>And the code to call the Sub would look like:<BR><BR>if strBandName <> "" then Inse*****d(strBandName, strBandNick)<BR><BR>hth,<BR>Alex<BR><BR>ASP.NET Examples/Tips: http://aspalliance.com/aldotnet<BR>hth,<BR>That helped greatly. Thanks Alex.
 
Back
Top