Need Help...Using button to call function.
-
Hey All, I am still new to asp.net and learning the ropes. I keep going around in circles on this one and I can't seem to find any resource or person that can help me out. A little information before I start: I am using 1.1 in vb. Here's the situation: I have a shopping page where the user confirms their order information and then clicks a button that say's "Verify Order". The information on that page is contained in asp:labels: Then I have a function in code behind that takes the values from the labels and inserts them as a new row in an access db. I'll post just a little bit of the code below: Public Function ConfInsert( _ ByVal cardAmount As String, _ ByVal deliveryMethod As String, _ ByVal recipientName As String, _ ByVal recipientAddress As String, _ ByVal recipientCity As String, _ ByVal recipientState As String, _ ByVal recipientZip As String, _ ByVal recipientPhone As String, _ ByVal recipientEmail As String, _ ByVal senderName As String, _ ByVal billingName As String, _ ByVal billingAddress As String, _ ByVal billingCity As String, _ ByVal billingState As String, _ ByVal billingZip As String, _ ByVal billingPhone As String, _ ByVal billingEmail As String, _ ByVal Sender As Object, _ ByVal e As EventArgs) Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=" <---Omitted for this post! Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString) Dim queryString As String = "INSERT INTO [GCOrders] ([CardAmount], [DeliveryMethod], [RecipientName], [Recipie"& _ "ntAddress], [RecipientCity], [RecipientState], [RecipientZip], [RecipientPhone],"& _ " [RecipientEmail], [SenderName], [BillingName], [BillingAddress], [BillingCity],"& _ " [BillingState], [BillingZip], [BillingPhone], [BillingEmail]) VALUES (@CardAmou"& _ "nt, @DeliveryMethod, @RecipientName, @RecipientAddress, @RecipientCity, @Recipie"& _ "ntState, @RecipientZip, @RecipientPhone, @RecipientEmail, @SenderName, @BillingN"& _
what exactly is your question? how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06
-
what exactly is your question? how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06
Sorry about that. I was just focused on getting the issue up there. The problem I am having is that it keeps throwing errors: BC30408: Method 'Public Function ConfInsert(..., Sender As Object, e As System.EventArgs) As Object' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'. I took out some of the wording on the function error above because of wordiness. The only resource I found on the net was for there to be a Sub event handler, but this is a function. John
-
Sorry about that. I was just focused on getting the issue up there. The problem I am having is that it keeps throwing errors: BC30408: Method 'Public Function ConfInsert(..., Sender As Object, e As System.EventArgs) As Object' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'. I took out some of the wording on the function error above because of wordiness. The only resource I found on the net was for there to be a Sub event handler, but this is a function. John
What that means is that any method for a button has to have the variables (ByVal sender As Object, ByVal e As System.EventArgs) Then you can call another method or function from inside the method that handles the button click event. For Example, Protect Sub Button1_Clicked (ByVal sender As Object, ByVal e As System.EventArgs) handles Button1_Click 'put code to call insert function here End Sub Does that make sense? how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06 -- modified at 9:40 Wednesday 22nd March, 2006
-
What that means is that any method for a button has to have the variables (ByVal sender As Object, ByVal e As System.EventArgs) Then you can call another method or function from inside the method that handles the button click event. For Example, Protect Sub Button1_Clicked (ByVal sender As Object, ByVal e As System.EventArgs) handles Button1_Click 'put code to call insert function here End Sub Does that make sense? how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06 -- modified at 9:40 Wednesday 22nd March, 2006
Okay, that makes sense. So I added the Sub to handle the button click but now I'm getting another error. Here's the Sub I created (I think it's correct) Public Sub ConfInsert (ByVal sender As Object, ByVal e As System.EventArgs) handles Confbtn.Click dim conf as string conf = funcConfInsert End Sub Here's the new error that I am getting: BC30455: Argument not specified for parameter 'billingAddress' of 'Public Function funcConfInsert(cardAmount As String, deliveryMethod As String, recipientName As String, recipientAddress As String, recipientCity As String, recipientState As String, recipientZip As String, recipientPhone As String, recipientEmail As String, senderName As String, billingName As String, billingAddress As String, billingCity As String, billingState As String, billingZip As String, billingPhone As String, billingEmail As String) As Object'. So, I took a look at the parameter code. First the SQL statement: Dim queryString As String = "INSERT INTO [GCOrders] ([CardAmount], [DeliveryMethod], [RecipientName], [Recipie"& _ "ntAddress], [RecipientCity], [RecipientState], [RecipientZip], [RecipientPhone],"& _ " [RecipientEmail], [SenderName], [BillingName], [BillingAddress], [BillingCity],"& _ " [BillingState], [BillingZip], [BillingPhone], [BillingEmail]) VALUES (@CardAmou"& _ "nt, @DeliveryMethod, @RecipientName, @RecipientAddress, @RecipientCity, @Recipie"& _ "ntState, @RecipientZip, @RecipientPhone, @RecipientEmail, @SenderName, @BillingN"& _ "ame, @BillingAddress, @BillingCity, @BillingState, @BillingZip, @BillingPhone, @"& _ "BillingEmail)" Then the individual parameter "billingAddress": Dim dbParam_billingAddress As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter dbParam_billingAddress.ParameterName = "@BillingAddress" dbParam_billingAddress.Value = LblBAddress.text dbParam_billingAddress.DbType = System.Data.DbType.[String] dbCommand.Parameters.Add(dbParam_billingAddress) What am I doing wrong? It threw the error on the Sub but is referencing a problem with the parameter. I don't understand. John
-
Okay, that makes sense. So I added the Sub to handle the button click but now I'm getting another error. Here's the Sub I created (I think it's correct) Public Sub ConfInsert (ByVal sender As Object, ByVal e As System.EventArgs) handles Confbtn.Click dim conf as string conf = funcConfInsert End Sub Here's the new error that I am getting: BC30455: Argument not specified for parameter 'billingAddress' of 'Public Function funcConfInsert(cardAmount As String, deliveryMethod As String, recipientName As String, recipientAddress As String, recipientCity As String, recipientState As String, recipientZip As String, recipientPhone As String, recipientEmail As String, senderName As String, billingName As String, billingAddress As String, billingCity As String, billingState As String, billingZip As String, billingPhone As String, billingEmail As String) As Object'. So, I took a look at the parameter code. First the SQL statement: Dim queryString As String = "INSERT INTO [GCOrders] ([CardAmount], [DeliveryMethod], [RecipientName], [Recipie"& _ "ntAddress], [RecipientCity], [RecipientState], [RecipientZip], [RecipientPhone],"& _ " [RecipientEmail], [SenderName], [BillingName], [BillingAddress], [BillingCity],"& _ " [BillingState], [BillingZip], [BillingPhone], [BillingEmail]) VALUES (@CardAmou"& _ "nt, @DeliveryMethod, @RecipientName, @RecipientAddress, @RecipientCity, @Recipie"& _ "ntState, @RecipientZip, @RecipientPhone, @RecipientEmail, @SenderName, @BillingN"& _ "ame, @BillingAddress, @BillingCity, @BillingState, @BillingZip, @BillingPhone, @"& _ "BillingEmail)" Then the individual parameter "billingAddress": Dim dbParam_billingAddress As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter dbParam_billingAddress.ParameterName = "@BillingAddress" dbParam_billingAddress.Value = LblBAddress.text dbParam_billingAddress.DbType = System.Data.DbType.[String] dbCommand.Parameters.Add(dbParam_billingAddress) What am I doing wrong? It threw the error on the Sub but is referencing a problem with the parameter. I don't understand. John
Double check the line of code where you call the function funcConfInsert. You are missing an argument. Also make sure you turn option strict on when working with vb.net. It will force you to write better code. how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things --thedailywtf 3/21/06
-
Sorry about that. I was just focused on getting the issue up there. The problem I am having is that it keeps throwing errors: BC30408: Method 'Public Function ConfInsert(..., Sender As Object, e As System.EventArgs) As Object' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'. I took out some of the wording on the function error above because of wordiness. The only resource I found on the net was for there to be a Sub event handler, but this is a function. John
-
John Wooton wrote:
does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.
Did you define your event handler correctly? 1 line of code equals many bugs. So don't write any!!
Hi Ista, Todd was helping me out there, and I actually made the error of calling a function directly from the button instead of using a sub as an event handler. Here's what I worte, but it's still throwing errors. Todd seemed to think that I was missing an argument in the line that calls the function. I can't seem to figure it out. Can you think of what I might be missing. Here's the event handler: Sub ConfInsert(sender As Object, e As EventArgs) handles Confbtn.click dim conf as string conf = funcConfInsert End Sub Also, normally I don't write the code myself. I usually have the program do it for me. Saves me a bunch of time, but this code I had to write myself.
-
Hi Ista, Todd was helping me out there, and I actually made the error of calling a function directly from the button instead of using a sub as an event handler. Here's what I worte, but it's still throwing errors. Todd seemed to think that I was missing an argument in the line that calls the function. I can't seem to figure it out. Can you think of what I might be missing. Here's the event handler: Sub ConfInsert(sender As Object, e As EventArgs) handles Confbtn.click dim conf as string conf = funcConfInsert End Sub Also, normally I don't write the code myself. I usually have the program do it for me. Saves me a bunch of time, but this code I had to write myself.
ok something confusing you have confInsert with a bunch of parameters and then this one The one above will work for handling the click event. Are you getting an error. Whats the entire text of the error including the stack trace? WHen you define a delegate the parameters must be the same. Since your basically creating a callback function. So it will call the same function. Nick 1 line of code equals many bugs. So don't write any!!
-
Hi Ista, Todd was helping me out there, and I actually made the error of calling a function directly from the button instead of using a sub as an event handler. Here's what I worte, but it's still throwing errors. Todd seemed to think that I was missing an argument in the line that calls the function. I can't seem to figure it out. Can you think of what I might be missing. Here's the event handler: Sub ConfInsert(sender As Object, e As EventArgs) handles Confbtn.click dim conf as string conf = funcConfInsert End Sub Also, normally I don't write the code myself. I usually have the program do it for me. Saves me a bunch of time, but this code I had to write myself.
-
ok something confusing you have confInsert with a bunch of parameters and then this one The one above will work for handling the click event. Are you getting an error. Whats the entire text of the error including the stack trace? WHen you define a delegate the parameters must be the same. Since your basically creating a callback function. So it will call the same function. Nick 1 line of code equals many bugs. So don't write any!!
Hey Nick, I emailed you a reply. Let me know if there's anything you can do to help me. I just didn't want to put a bunch of secure code in a public forum. John