hi i have the foolowing code
Dim pm1 As New MySqlParameter
Dim pm2 As New MySqlParameter
cmdMain = New MySqlCommand("rInsertCustomer", cnMain)
cmdMain.CommandType = CommandType.StoredProcedure
''cmdMain.Parameters.Add(AddSQLParam("CustomerId", SqlDbType.Int, ParameterDirection.Input, 9))
''cmdMain.Parameters.Add(AddSQLParam("CustomerName", SqlDbType.VarChar, ParameterDirection.Input, "Test"))
pm1 = New MySqlParameter("CustomerId", MySqlDbType.Int16, 0)
pm1.Direction = ParameterDirection.Input
pm1.Value = 9
cmdMain.Parameters.Add(pm1)
pm2 = New MySqlParameter("CustomerName", MySqlDbType.VarChar, 45)
pm2.Direction = ParameterDirection.Input
pm2.Value = "Test"
cmdMain.Parameters.Add(pm2)
'cmdMain.Parameters.AddWithValue("CustomerID", 9)
'cmdMain.Parameters.AddWithValue("CustomerName", "Test")
cmdMain.ExecuteNonQuery()
the db connects ok in another procedure.
the routine in mysql is as follows:
CREATE DEFINER=`root`@`localhost` PROCEDURE `rInsertCustomer`(
IN CustomerId INT,
IN CustomerName VARCHAR(45)
)
BEGIN
INSERT INTO tblCustomer
(
CustomerId,
CustomerName
)
VALUES
(
@CustomerId,
@CustomerName
);
END
when i run the executenonquery i get the error:
Column 'CustomerId' Cannot be null
any ideas.
thanks
Dim pm1 As New MySqlParameter
Dim pm2 As New MySqlParameter
cmdMain = New MySqlCommand("rInsertCustomer", cnMain)
cmdMain.CommandType = CommandType.StoredProcedure
''cmdMain.Parameters.Add(AddSQLParam("CustomerId", SqlDbType.Int, ParameterDirection.Input, 9))
''cmdMain.Parameters.Add(AddSQLParam("CustomerName", SqlDbType.VarChar, ParameterDirection.Input, "Test"))
pm1 = New MySqlParameter("CustomerId", MySqlDbType.Int16, 0)
pm1.Direction = ParameterDirection.Input
pm1.Value = 9
cmdMain.Parameters.Add(pm1)
pm2 = New MySqlParameter("CustomerName", MySqlDbType.VarChar, 45)
pm2.Direction = ParameterDirection.Input
pm2.Value = "Test"
cmdMain.Parameters.Add(pm2)
'cmdMain.Parameters.AddWithValue("CustomerID", 9)
'cmdMain.Parameters.AddWithValue("CustomerName", "Test")
cmdMain.ExecuteNonQuery()
the db connects ok in another procedure.
the routine in mysql is as follows:
CREATE DEFINER=`root`@`localhost` PROCEDURE `rInsertCustomer`(
IN CustomerId INT,
IN CustomerName VARCHAR(45)
)
BEGIN
INSERT INTO tblCustomer
(
CustomerId,
CustomerName
)
VALUES
(
@CustomerId,
@CustomerName
);
END
when i run the executenonquery i get the error:
Column 'CustomerId' Cannot be null
any ideas.
thanks