hi, my name is ivan,i am new to stored procedure and VB.Net, i am trying to insert a value to a column in a table in my database using VB.Net and Stored procedure
Here's the procedure:
1. A user will input a value to a textbox, for example lastname.
2. When the user click the save button, the button will call the stored procedure.
Here's my code in stored procedure:
And here's my code in VB.Net in save button:
And i got this error message:
ERROR[HY000][MySQL][ODBC 3.51 Driver][mysqld-5.0.37] Incorrect number of arguments for procedure sp_tutorial.sp_ addCustomer; expected 1,got 0
Please help me, i want to learn more in VB.Net and stored procedure.
Here's the procedure:
1. A user will input a value to a textbox, for example lastname.
2. When the user click the save button, the button will call the stored procedure.
Here's my code in stored procedure:
Code:
DELIMITER $$ DROP PROCEDURE IF EXISTS `sp_tutorial`.`sp_addCustomer` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_addCustomer`(lastname char(255)) BEGIN insert into table_customer(cust_lname) values(lastname); END $$ DELIMITER ;
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim password As String
password = ""
Dim conn As New Odbc.OdbcConnection
Dim cmd As New Odbc.OdbcCommand
conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" + "Server=localhost;" + "Database=sp_tutorial;" + "Uid=root;" + "Pwd=" & password & ";"
Try
conn.Open()
cmd.Connection = conn
cmd.CommandText = "call sp_addCustomer"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("lastname", Odbc.OdbcType.NVarChar, 255)
cmd.Parameters.AddWithValue("lastname", TextBox1.Text)
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
And i got this error message:
ERROR[HY000][MySQL][ODBC 3.51 Driver][mysqld-5.0.37] Incorrect number of arguments for procedure sp_tutorial.sp_ addCustomer; expected 1,got 0
Please help me, i want to learn more in VB.Net and stored procedure.
Comment